|
|
|
@ -85,23 +85,18 @@ const url = "";
|
|
|
|
|
const format = "DD-MM-YYYY"; |
|
|
|
|
|
|
|
|
|
const CreatedProyek = ({ params, ...props }) => { |
|
|
|
|
let role_id = '', user_id = '', proyek_id = '', isLogin = '', token = '', company_id = 0, all_project = ''; |
|
|
|
|
if (props.location.state && props.location.state.role_id && props.location.state.user_id) { |
|
|
|
|
role_id = props.location.state.role_id; |
|
|
|
|
user_id = props.location.state.user_id; |
|
|
|
|
token = props.location.state.token; |
|
|
|
|
isLogin = props.location.state.isLogin; |
|
|
|
|
company_id = props.location.state.company_id; |
|
|
|
|
all_project = props.location.state.all_project; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
role_id = localStorage.getItem("role_id"); |
|
|
|
|
proyek_id = localStorage.getItem("proyek_id"); |
|
|
|
|
user_id = localStorage.getItem("user_id"); |
|
|
|
|
token = localStorage.getItem("token"); |
|
|
|
|
isLogin = localStorage.getItem("isLogin"); |
|
|
|
|
company_id = localStorage.getItem('company_id'); |
|
|
|
|
all_project = localStorage.getItem('all_project'); |
|
|
|
|
let role_id = 0, user_id = 0, isLogin = false, token = '', company_id = 0, all_project = null, role_name='', hierarchy=[], user_name=''; |
|
|
|
|
if (props && props.role_id && props.user_id) { |
|
|
|
|
role_id = props.role_id; |
|
|
|
|
user_id = props.user_id; |
|
|
|
|
token = props.token; |
|
|
|
|
isLogin = props.isLogin; |
|
|
|
|
company_id = props.company_id; |
|
|
|
|
all_project = props.all_project; |
|
|
|
|
role_name = props.role_name; |
|
|
|
|
isLogin = props.isLogin; |
|
|
|
|
hierarchy = props.hierarchy; |
|
|
|
|
user_name = props.user_name; |
|
|
|
|
} |
|
|
|
|
const history = useHistory(); |
|
|
|
|
const HEADER = { |
|
|
|
@ -335,21 +330,35 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const getDataProyek = async () => { |
|
|
|
|
setLoading(true); |
|
|
|
|
let start = 0; |
|
|
|
|
let hierarchy = []; |
|
|
|
|
hierarchy.push(JSON.parse(localStorage.getItem("hierarchy"))); |
|
|
|
|
if (currentPage !== 1 && currentPage > 1) { |
|
|
|
|
start = currentPage * rowsPerPage - rowsPerPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
columns: [ |
|
|
|
|
columns: [], |
|
|
|
|
group_column: { |
|
|
|
|
"operator": "AND", |
|
|
|
|
"group_operator": "OR", |
|
|
|
|
"where": [ |
|
|
|
|
{ |
|
|
|
|
name: "nama", |
|
|
|
|
logic_operator: "ilike", |
|
|
|
|
value: search, |
|
|
|
|
operator: "AND", |
|
|
|
|
"name": "nama", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
"table_name": "m_type_proyek" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
"table_name": "m_users" |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
select: [ |
|
|
|
|
"id", |
|
|
|
|
"nama", |
|
|
|
@ -369,21 +378,28 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
name: "m_type_proyek", |
|
|
|
|
column_join: "type_proyek_id", |
|
|
|
|
column_results: ["name", "description"], |
|
|
|
|
}, |
|
|
|
|
// { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }
|
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
orders: { columns: ["nama"], ascending: true }, |
|
|
|
|
paging: { start: start, length: rowsPerPage }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (all_project !== null && all_project === true) { |
|
|
|
|
payload["columns"] = [ |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } |
|
|
|
|
]; |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
if(role_name !== 'Super Admin') { |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
payload["columns"] = [ |
|
|
|
|
{ name: "created_by_id", logic_operator: "IN", value: hierarchy, 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 |
|
|
|
@ -512,7 +528,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleOpenDialogGantt = (data) => { |
|
|
|
|
console.log('data.mulai_proyek', data.mulai_proyek); |
|
|
|
|
setDataViewStartDate(data.mulai_proyek) |
|
|
|
|
setidTask(data.id); |
|
|
|
|
setProyekName(data.nama); |
|
|
|
@ -569,7 +584,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const handleOpenDialogViewDetail = async (data) => { |
|
|
|
|
setLoading(true); |
|
|
|
|
setidTask(data.id); |
|
|
|
|
// setDataView(data)
|
|
|
|
|
await getDataProject(data.id); |
|
|
|
|
await getProjectMilestone(data.id); |
|
|
|
|
await getProjectParticipant(data.id); |
|
|
|
@ -580,7 +594,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
await getK3toProject(data.id); |
|
|
|
|
await getProjectAssignHR(data.id); |
|
|
|
|
await getProjectImage(data.id); |
|
|
|
|
// await handleGetDataPm(data.id);
|
|
|
|
|
setPM(data.join_first_name); |
|
|
|
|
setOpenDialogViewDetail(true); |
|
|
|
|
}; |
|
|
|
@ -679,7 +692,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
orders: { columns: ["id"], ascending: true }, |
|
|
|
|
paging: { start: 0, length: -1 }, |
|
|
|
|
}; |
|
|
|
|
// const url = PROJECT_MI(proyek_id)
|
|
|
|
|
const result = await axios |
|
|
|
|
.post(PROJECT_MILESTONE_SEARCH, payload, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
@ -718,7 +730,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
orders: { columns: ["id"], ascending: true }, |
|
|
|
|
paging: { start: 0, length: -1 }, |
|
|
|
|
}; |
|
|
|
|
// const url = PROJECT_MI(proyek_id)
|
|
|
|
|
const result = await axios |
|
|
|
|
.post(ASSIGN_HR_PROJECT_SEARCH, payload, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
@ -1313,13 +1324,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
const arr = await Promise.all(request) |
|
|
|
|
.then((values) => values) |
|
|
|
|
.catch((err) => err.response); |
|
|
|
|
// if(arr)
|
|
|
|
|
|
|
|
|
|
// const result = arr.map(res => res.data.code !== 200)
|
|
|
|
|
// if (result.length > 0) {
|
|
|
|
|
// return "gagal"
|
|
|
|
|
// }
|
|
|
|
|
// return "berhasil"
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handleDelete = async (id) => { |
|
|
|
@ -1337,15 +1341,40 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
|
|
|
|
|
const handleExportExcel = async () => { |
|
|
|
|
const payload = { |
|
|
|
|
columns:[], |
|
|
|
|
group_column: { |
|
|
|
|
"operator": "AND", |
|
|
|
|
"group_operator": "OR", |
|
|
|
|
"where": [ |
|
|
|
|
{ |
|
|
|
|
"name": "nama", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
paging: { start: 0, length: -1 }, |
|
|
|
|
joins: [], |
|
|
|
|
orders: { columns: ["id"], ascending: false }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (parseInt(role_id) !== 1) { |
|
|
|
|
payload["columns"] = [ |
|
|
|
|
{ name: "id", logic_operator: "=", value: proyek_id, operator: "AND" }, |
|
|
|
|
]; |
|
|
|
|
if (all_project !== null && all_project === true) { |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(role_name !== 'Super Admin') { |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
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 |
|
|
|
@ -1357,30 +1386,33 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
let resData = result.data.data; |
|
|
|
|
const excelData = []; |
|
|
|
|
resData.map((n, index) => { |
|
|
|
|
let dataRow = { |
|
|
|
|
Sortname: n.kode_sortname ? n.kode_sortname : "", |
|
|
|
|
"Nama Project": n.nama ? n.nama : "", |
|
|
|
|
"Tanggal Mulai": n.mulai_proyek |
|
|
|
|
let dataRow = {}; |
|
|
|
|
if (role_name === 'Super Admin') { |
|
|
|
|
dataRow.Company = n.join_first_company_name; |
|
|
|
|
} |
|
|
|
|
dataRow.Sortname = n.kode_sortname ? n.kode_sortname : ""; |
|
|
|
|
dataRow["Nama Project"] = n.nama ? n.nama : ""; |
|
|
|
|
dataRow["Tanggal Mulai"] = n.mulai_proyek |
|
|
|
|
? moment(n.mulai_proyek).format(format) |
|
|
|
|
: "-", |
|
|
|
|
"Tanggal Selesai": n.akhir_proyek |
|
|
|
|
: "-"; |
|
|
|
|
dataRow["Tanggal Selesai"] = n.akhir_proyek |
|
|
|
|
? moment(n.akhir_proyek).format(format) |
|
|
|
|
: "-", |
|
|
|
|
"Area Kerja": n.area_kerja ? n.area_kerja : "", |
|
|
|
|
Perusahaan: n.company ? n.company : "", |
|
|
|
|
Keterangan: n.keterangan ? n.keterangan : "", |
|
|
|
|
"Dianggap sukses ketika": n.considered_success_when |
|
|
|
|
: "-"; |
|
|
|
|
dataRow["Area Kerja"] = n.area_kerja ? n.area_kerja : ""; |
|
|
|
|
dataRow["Perusahaan"] = n.company ? n.company : ""; |
|
|
|
|
dataRow["Keterangan"] = n.keterangan ? n.keterangan : ""; |
|
|
|
|
dataRow["Dianggap sukses ketika"] = n.considered_success_when |
|
|
|
|
? n.considered_success_when |
|
|
|
|
: "", |
|
|
|
|
"Tujuan Proyek": n.project_objectives ? n.project_objectives : "", |
|
|
|
|
"Resiko potensial": n.potential_risk ? n.potential_risk : "", |
|
|
|
|
"Rencana Biaya": n.rencana_biaya |
|
|
|
|
: ""; |
|
|
|
|
dataRow["Tujuan Proyek"] = n.project_objectives ? n.project_objectives : ""; |
|
|
|
|
dataRow["Resiko potensial"] = n.potential_risk ? n.potential_risk : ""; |
|
|
|
|
dataRow["Rencana Biaya"] = n.rencana_biaya |
|
|
|
|
? formatThousand(n.rencana_biaya) |
|
|
|
|
: "-", |
|
|
|
|
"Testing Environment": n.testing_environment |
|
|
|
|
: "-"; |
|
|
|
|
dataRow["Testing Environment"] = n.testing_environment |
|
|
|
|
? n.testing_environment |
|
|
|
|
: "-", |
|
|
|
|
}; |
|
|
|
|
: "-"; |
|
|
|
|
|
|
|
|
|
excelData.push(dataRow); |
|
|
|
|
}); |
|
|
|
|
await setDataExport(excelData); |
|
|
|
@ -1391,19 +1423,35 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
|
|
|
|
|
const handleExportPdf = async () => { |
|
|
|
|
const doc = new jsPDF(); |
|
|
|
|
|
|
|
|
|
const headers = [ |
|
|
|
|
["Project Name", "Budget", "Project Type", "PM", "Time Project"], |
|
|
|
|
let headers = [ |
|
|
|
|
[role_name === 'Super Admin' ? "Company" : null,"Project Name", "Budget", "Project Type", "PM", "Time Project"], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
const payload = { |
|
|
|
|
columns: [ |
|
|
|
|
columns:[], |
|
|
|
|
group_column: { |
|
|
|
|
"operator": "AND", |
|
|
|
|
"group_operator": "OR", |
|
|
|
|
"where": [ |
|
|
|
|
{ |
|
|
|
|
name: "nama", |
|
|
|
|
logic_operator: "ilike", |
|
|
|
|
value: search, |
|
|
|
|
operator: "AND", |
|
|
|
|
"name": "nama", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
"table_name": "m_type_proyek" |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
"name": "name", |
|
|
|
|
"logic_operator": "~*", |
|
|
|
|
"value": search, |
|
|
|
|
"table_name": "m_users" |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
joins: [ |
|
|
|
|
{ |
|
|
|
|
name: "m_users", |
|
|
|
@ -1415,11 +1463,28 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
column_join: "type_proyek_id", |
|
|
|
|
column_results: ["name", "description"], |
|
|
|
|
}, |
|
|
|
|
// { "name": "subproyeks.m_subproyek", "column_join": "parent_id", "column_results": ["nama", "biaya", "color_progress", "jumlah_pekerja", "pic", "mulai_proyek", "akhir_proyek", "biaya_actual", "persentase_progress_plan", "persentase_progress_actual"] }
|
|
|
|
|
], |
|
|
|
|
orders: { columns: ["nama"], ascending: true }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (all_project !== null && all_project === true) { |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ name: "company_id", logic_operator: "like", value: company_id, operator: "AND" } |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
if(role_name !== 'Super Admin') { |
|
|
|
|
payload.columns.push( |
|
|
|
|
{ name: "created_by_id", logic_operator: "IN", value: [JSON.parse(hierarchy)], operator: "AND" } |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
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(PROYEK_SEARCH, payload, HEADER) |
|
|
|
|
.then((res) => res) |
|
|
|
@ -1427,6 +1492,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
if (result && result.data && result.data.code == 200) { |
|
|
|
|
let resData = result.data.data; |
|
|
|
|
const data = resData.map((elt) => [ |
|
|
|
|
role_name === 'Super Admin' ? elt.join_third_company_name : null, |
|
|
|
|
elt.nama, |
|
|
|
|
`Rp. ${formatThousand(elt.rencana_biaya)}`, |
|
|
|
|
elt.join_second_name, |
|
|
|
@ -1447,34 +1513,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
doc.save("Project.pdf"); |
|
|
|
|
// const unit = "pt";
|
|
|
|
|
// const size = "A4"; // Use A1, A2, A3 or A4
|
|
|
|
|
// const orientation = "portrait"; // portrait or landscape
|
|
|
|
|
|
|
|
|
|
// const marginLeft = 40;
|
|
|
|
|
// const doc = new jsPDF(orientation, unit, size);
|
|
|
|
|
|
|
|
|
|
// doc.setFontSize(15);
|
|
|
|
|
// const dataPeople = [
|
|
|
|
|
// { name: "Keanu Reeves", profession: "Actor" },
|
|
|
|
|
// { name: "Lionel Messi", profession: "Football Player" },
|
|
|
|
|
// { name: "Cristiano Ronaldo", profession: "Football Player" },
|
|
|
|
|
// { name: "Jack Nicklaus", profession: "Golf Player" },
|
|
|
|
|
// ];
|
|
|
|
|
// const title = "My Awesome Report";
|
|
|
|
|
// const headers = [["NAME", "PROFESSION"]];
|
|
|
|
|
|
|
|
|
|
// const data = dataPeople.map((elt) => [elt.name, elt.profession]);
|
|
|
|
|
|
|
|
|
|
// let content = {
|
|
|
|
|
// startY: 50,
|
|
|
|
|
// head: headers,
|
|
|
|
|
// body: data,
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// doc.text(title, marginLeft, 40);
|
|
|
|
|
// doc.autoTable(content);
|
|
|
|
|
// doc.save("report.pdf");
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const exportExcel = () => { |
|
|
|
@ -1688,12 +1726,21 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
</> |
|
|
|
|
), |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
title: role_name === 'Super Admin' ? "Company Name" : null, |
|
|
|
|
dataIndex: "join_third_company_name", |
|
|
|
|
key: "join_third_company_name", |
|
|
|
|
render: (text, record) => { |
|
|
|
|
return role_name === 'Super Admin' ? ( |
|
|
|
|
<span>{record.join_third_company_name}</span> |
|
|
|
|
) : null; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
{ title: "Project Name", dataIndex: "nama", key: "nama" }, |
|
|
|
|
{ |
|
|
|
|
title: "Budget", |
|
|
|
|
dataIndex: "rencana_biaya", |
|
|
|
|
key: "rencana_biaya", |
|
|
|
|
// render: (text, record) => { return renderFormatRupiah(text, "Rp") }
|
|
|
|
|
render: (text, record) => { |
|
|
|
|
return record.currency_symbol |
|
|
|
|
? `${record.currency_symbol} ${formatThousand(text)}` |
|
|
|
@ -2022,7 +2069,7 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
type="text" |
|
|
|
|
name="search" |
|
|
|
|
id="search" |
|
|
|
|
placeholder={`Search Project Name`} |
|
|
|
|
placeholder={`Search...`} |
|
|
|
|
style={{ width: 200 }} |
|
|
|
|
/> |
|
|
|
|
</Col> |
|
|
|
@ -2039,7 +2086,6 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
)} |
|
|
|
|
<Tooltip title="Export"> |
|
|
|
|
<Popover |
|
|
|
|
// content={<a onClick={hide}>Close</a>}
|
|
|
|
|
title="Export" |
|
|
|
|
trigger="click" |
|
|
|
|
placement="leftBottom" |
|
|
|
@ -2064,12 +2110,9 @@ const CreatedProyek = ({ params, ...props }) => {
|
|
|
|
|
</Button> |
|
|
|
|
</> |
|
|
|
|
} |
|
|
|
|
// visible={visible}
|
|
|
|
|
// onVisibleChange={handleVisibleChange}
|
|
|
|
|
> |
|
|
|
|
<Button |
|
|
|
|
style={{ marginLeft: "5px" }} |
|
|
|
|
// onClick={() => handleExportExcel()}
|
|
|
|
|
> |
|
|
|
|
<i className="fa fa-print"></i> |
|
|
|
|
</Button> |
|
|
|
|