diff --git a/src/views/Master/ProjectPhase/index.js b/src/views/Master/ProjectPhase/index.js index 78b914a..71239f3 100644 --- a/src/views/Master/ProjectPhase/index.js +++ b/src/views/Master/ProjectPhase/index.js @@ -67,14 +67,18 @@ const ProjectPhase = ({ params, ...props }) => { start = (currentPage * rowsPerPage) - rowsPerPage } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "ilike", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -84,7 +88,8 @@ const ProjectPhase = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { payload.columns.push( @@ -94,6 +99,12 @@ const ProjectPhase = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios .post(PROJECT_PHASE_SEARCH, payload, HEADER) @@ -129,14 +140,18 @@ const ProjectPhase = ({ params, ...props }) => { } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "like", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -146,7 +161,23 @@ const ProjectPhase = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] + } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios @@ -157,10 +188,12 @@ const ProjectPhase = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama": val.name, - "Color": val.color, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow.Nama=val.name; + dataRow.Color=val.color; excelData.push(dataRow) }) await setDataExport(excelData) @@ -308,6 +341,16 @@ const ProjectPhase = ({ params, ...props }) => { {" "} , }, + { + title: role_name === 'Super Admin' ? "Company Name" : null, + dataIndex: "join_first_company_name", + key: "join_first_company_name", + render: (text, record) => { + return role_name === 'Super Admin' ? ( + {record.join_first_company_name} + ) : null; + } + }, { title: t('phase'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: t('color'), diff --git a/src/views/SimproV2/ChecklistK3/index.js b/src/views/SimproV2/ChecklistK3/index.js index 0ba72c1..4d538ca 100644 --- a/src/views/SimproV2/ChecklistK3/index.js +++ b/src/views/SimproV2/ChecklistK3/index.js @@ -47,6 +47,7 @@ const ChecklistK3 = ({ params }) => { const [typeDialog, setTypeDialog] = useState('Save') const { t } = useTranslation() const column = [ + { name: "Company Name" }, { name: t('name') }, { name: t('description') }, ] @@ -70,14 +71,18 @@ const ChecklistK3 = ({ params }) => { } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "ilike", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -87,7 +92,8 @@ const ChecklistK3 = ({ params }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { @@ -98,6 +104,12 @@ const ChecklistK3 = ({ params }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios @@ -126,13 +138,37 @@ const ChecklistK3 = ({ params }) => { const handleExportExcel = async () => { const payload = { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" } - ], + "columns": [], "joins": [], "orders": { "columns": ["id"], "ascending": false } } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) + } const result = await axios .post(CHECKLIST_K3_SEARCH, payload, config) @@ -143,10 +179,12 @@ const ChecklistK3 = ({ params }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama": val.name, - "Deskripsi": val.description, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow.Nama=val.name; + dataRow.Deskripsi=val.description; excelData.push(dataRow) }) await setDataExport(excelData); @@ -329,6 +367,11 @@ const ChecklistK3 = ({ params }) => { handleEdit(n)}> + {role_name === 'Super Admin'&& + ( + {n.join_first_company_name} + ) + } {n.name} {n.description} diff --git a/src/views/SimproV2/Divisi/index.js b/src/views/SimproV2/Divisi/index.js index 386919d..a3b2866 100644 --- a/src/views/SimproV2/Divisi/index.js +++ b/src/views/SimproV2/Divisi/index.js @@ -11,7 +11,8 @@ import { useTranslation } from 'react-i18next'; const column = [ - { name: "Nama" }, + { name: "Company Name" }, + { name: "Nama Divisi" }, { name: "Deskripsi" }, { name: "Color" }, ] @@ -67,6 +68,17 @@ const ProjectType = ({ params, ...props }) => { const getListDivision = async () => { const payload = { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, columns: [], "orders": { "ascending": true, @@ -77,7 +89,8 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": 0, "start": -1 - } + }, + 'joins': [] } if (role_name !== "Super Admin") { @@ -88,6 +101,12 @@ const ProjectType = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const listDivions = await axios .post(DIVISI_SEARCH, payload, HEADER) @@ -112,14 +131,18 @@ const ProjectType = ({ params, ...props }) => { start = currentPage * rowsPerPage - rowsPerPage; } const payload = { - columns: [ - { - name: "name", - logic_operator: "ilike", - value: search, - operator: "AND" - }, - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + columns: [], "orders": { "ascending": true, "columns": [ @@ -129,7 +152,8 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { @@ -140,6 +164,12 @@ const ProjectType = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios .post(DIVISI_SEARCH, payload, HEADER) @@ -162,14 +192,18 @@ const ProjectType = ({ params, ...props }) => { } const payload = { - "columns": [ - { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { "name": "name", - "logic_operator": "like", + "logic_operator": "~*", "value": search, - "operator": "AND" - } - ], + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -179,9 +213,24 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] + } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } - const result = await axios .post(DIVISI_SEARCH, payload, HEADER) .then(res => res) @@ -190,10 +239,12 @@ const ProjectType = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama Divisi": val.name, - "Deskripsi": val.description, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow["Nama Divisi"]=val.name; + dataRow.Deskripsi=val.description; excelData.push(dataRow) }) await setDataExport(excelData) @@ -385,6 +436,11 @@ const ProjectType = ({ params, ...props }) => { handleEdit(n)}> + {role_name === 'Super Admin'&& + ( + {n.join_first_company_name} + ) + } {n.name} {n.description ?? '-'} {n.color != null ? ( diff --git a/src/views/SimproV2/ProjectType/index.js b/src/views/SimproV2/ProjectType/index.js index ba95481..da49642 100644 --- a/src/views/SimproV2/ProjectType/index.js +++ b/src/views/SimproV2/ProjectType/index.js @@ -70,14 +70,18 @@ const ProjectType = ({ params, ...props }) => { } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "like", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": false, "columns": [ @@ -87,7 +91,8 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { payload.columns.push( @@ -97,6 +102,12 @@ const ProjectType = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios .post(PROJECT_TYPE_SEARCH, payload, HEADER, HEADER) @@ -130,14 +141,18 @@ const ProjectType = ({ params, ...props }) => { } const payload = { - "columns": [ - { - "name": "name", - "logic_operator": "like", - "value": search, - "operator": "AND" - } - ], + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -147,9 +162,24 @@ const ProjectType = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] + } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } - const result = await axios .post(PROJECT_TYPE_SEARCH, payload, HEADER) @@ -160,10 +190,12 @@ const ProjectType = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama": val.name, - "Deskripsi": val.description, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow.Nama=val.name; + dataRow.Deskripsi=val.description; excelData.push(dataRow) }) await setDataExport(excelData); @@ -314,6 +346,16 @@ const ProjectType = ({ params, ...props }) => { , }, + { + title: role_name === 'Super Admin' ? "Company Name" : null, + dataIndex: "join_first_company_name", + key: "join_first_company_name", + render: (text, record) => { + return role_name === 'Super Admin' ? ( + {record.join_first_company_name} + ) : null; + } + }, { title: t('nameProjectType'), dataIndex: 'name', key: 'name', className: "nowrap" }, { title: t('description'), dataIndex: 'description', key: 'description' }, ]; @@ -364,7 +406,7 @@ const ProjectType = ({ params, ...props }) => {

{pageName}

- + diff --git a/src/views/SimproV2/Satuan/index.js b/src/views/SimproV2/Satuan/index.js index 3c694bc..dfe0528 100644 --- a/src/views/SimproV2/Satuan/index.js +++ b/src/views/SimproV2/Satuan/index.js @@ -59,6 +59,7 @@ const Satuan = ({ params, ...props }) => { }, [dataExport]) const column = [ + { name: "Company Name" }, { name: t('name') }, { name: t('description') }, ] @@ -71,14 +72,18 @@ const Satuan = ({ params, ...props }) => { } const payload = { - "columns": [ - { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { "name": "name", - "logic_operator": "ilike", + "logic_operator": "~*", "value": search, - "operator": "AND" - } - ], + } + ] + }, + "columns": [], "orders": { "ascending": true, "columns": [ @@ -88,7 +93,8 @@ const Satuan = ({ params, ...props }) => { "paging": { "length": rowsPerPage, "start": start - } + }, + 'joins': [] } if (role_name !== "Super Admin") { @@ -99,6 +105,12 @@ const Satuan = ({ params, ...props }) => { payload.columns.push( { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } @@ -127,11 +139,36 @@ const Satuan = ({ params, ...props }) => { const handleExportExcel = async () => { const payload = { + group_column: { + "operator": "AND", + "group_operator": "OR", + "where": [ + { + "name": "name", + "logic_operator": "~*", + "value": search, + } + ] + }, "paging": { "start": 0, "length": -1 }, - "columns": [ - { "name": "name", "logic_operator": "ilike", "value": search, "operator": "AND" } - ], - "orders": { "columns": ["id"], "ascending": false } + "columns": [], + "orders": { "columns": ["id"], "ascending": false }, + 'joins': [] + } + if (role_name !== "Super Admin") { + payload.columns.push( + { "name": "company_id", "logic_operator": "=", "value": company_id, "operator": "AND" }, + ) + } else { + payload.columns.push( + { "name": "company_id", "logic_operator": "is null", "value": "", "operator": "AND" }, + ) + payload.joins.push( + { name: "m_company", column_join: "company_id", column_results: ["company_name"] } + ) + payload.group_column.where.push( + { name: "company_name", logic_operator: "~*", value: search, table_name: "m_company" } + ) } const result = await axios .post(SATUAN_SEARCH, payload, HEADER) @@ -141,10 +178,12 @@ const Satuan = ({ params, ...props }) => { let resData = result.data.data; const excelData = []; resData.map((val, index) => { - let dataRow = { - "Nama": val.name, - "Deskripsi": val.description, + let dataRow = {}; + if (role_name === 'Super Admin') { + dataRow.Company = val.join_first_company_name; } + dataRow.Nama=val.name; + dataRow.Deskripsi=val.description; excelData.push(dataRow) }) await setDataExport(excelData); @@ -328,6 +367,11 @@ const Satuan = ({ params, ...props }) => { handleEdit(n)}> + {role_name === 'Super Admin'&& + ( + {n.join_first_company_name} + ) + } {n.name} {n.description}