Commit 25eae3f3 authored by Internship UKSW 2019's avatar Internship UKSW 2019

Initial commit

parent 55891008
REACT_APP_MAIN_APIURL = "http://10.10.86.48:9000"
\ No newline at end of file
REACT_APP_MAIN_APIURL = "http://10.10.88.12:9000"
\ No newline at end of file
......@@ -56,10 +56,15 @@ export class DataTableApprovalDocument extends Component {
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
},
{
visible: false,
searchable: false,
orderable: false,
targets: 7
}
],
order: [[1, "asc"]],
lengthMenu: [[25, 50, 75, 100], [25, 50, 75, 100]]
order: [[1, "asc"]]
})
table.on("order.dt search.dt", function () {
table.column(0, { search: "applied", order: "applied" }).nodes().each(function (cell, i) {
......@@ -69,7 +74,7 @@ export class DataTableApprovalDocument extends Component {
table.on("click", "a", function (e) {
e.preventDefault();
let data = table.row($(this).parents("tr")).data();
window.open("http://10.10.86.48:3000/formapprover?subject=" + data[2], "_self");
window.open("http://" + localStorage.getItem('host') + "/formapprover?subject=" + data[2] + "&userid=" + data[7], "_self");
})
}
componentWillUnmount = () => {
......
......@@ -56,10 +56,15 @@ export class DataTableExpiredDocument extends Component {
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
},
{
visible: false,
searchable: false,
orderable: false,
targets: 7
}
],
order: [[1, "asc"]],
lengthMenu: [[25, 50, 75, 100], [25, 50, 75, 100]]
order: [[1, "asc"]]
})
table.on("order.dt search.dt", function () {
table.column(0, { search: "applied", order: "applied" }).nodes().each(function (cell, i) {
......@@ -69,7 +74,7 @@ export class DataTableExpiredDocument extends Component {
table.on("click", "a", function (e) {
e.preventDefault();
let data = table.row($(this).parents("tr")).data();
window.open("http://10.10.86.48:3000/previewdocument?subject=" + data[2], "_blank");
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + data[2] + "&userid=" + data[7], "_blank");
})
}
componentWillUnmount = () => {
......
......@@ -60,6 +60,12 @@ export class DataTableHome extends Component {
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
},
{
visible: false,
searchable: false,
orderable: false,
targets: 8
}
],
order: [[ 1, "asc" ]],
......@@ -73,7 +79,7 @@ export class DataTableHome extends Component {
table.on("click", "a", function (e) {
e.preventDefault();
let data = table.row($(this).parents("tr")).data();
window.open("http://10.10.86.48:3000/previewdocument?subject=" + data[2], "_blank");
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + data[2] + "&userid=" + data[8], "_blank");
})
}
componentWillUnmount = () => {
......
......@@ -58,16 +58,21 @@ export class DataTableMyDocument extends Component {
return "<div>" + data + "</div>";
}
},
{
visible: false,
searchable: false,
orderable: false,
targets: 7
},
{
orderable: false,
targets: 7,
targets: 8,
render: function (data, type, row) {
return "&nbsp;&nbsp;<a id='withdraw' class='text-decoration-none text-dark' href='#'><svg style='width:24px;height:24px' viewBox='0 0 24 24'><path fill='currentColor' d='M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z' /></svg></a>";
}
}
],
order: [[1, "asc"]],
lengthMenu: [[25, 50, 75, 100], [25, 50, 75, 100]]
order: [[1, "asc"]]
})
table.on("order.dt search.dt", function () {
table.column(0, { search: "applied", order: "applied" }).nodes().each(function (cell, i) {
......@@ -77,7 +82,7 @@ export class DataTableMyDocument extends Component {
table.on("click", "a#revision", function (e) {
e.preventDefault();
let data = table.row($(this).parents("tr")).data();
window.open("http://10.10.86.48:3000/formrevision?subject=" + data[2], "_self");
window.open("http://" + localStorage.getItem('host') + "/formrevision?subject=" + data[2] + "&userid=" + data[7], "_self");
})
table.on("click", "a#withdraw", function (e) {
e.preventDefault();
......
......@@ -56,10 +56,15 @@ export class DataTablePublishDocument extends Component {
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
},
{
visible: false,
searchable: false,
orderable: false,
targets: 7
}
],
order: [[1, "asc"]],
lengthMenu: [[25, 50, 75, 100], [25, 50, 75, 100]]
order: [[1, "asc"]]
})
table.on("order.dt search.dt", function () {
table.column(0, { search: "applied", order: "applied" }).nodes().each(function (cell, i) {
......@@ -69,7 +74,7 @@ export class DataTablePublishDocument extends Component {
table.on("click", "a", function (e) {
e.preventDefault();
let data = table.row($(this).parents("tr")).data();
window.open("http://10.10.86.48:3000/formpublish?subject=" + data[2], "_self");
window.open("http://" + localStorage.getItem('host') +"/formpublish?subject=" + data[2] + "&userid=" + data[7], "_self");
})
}
componentWillUnmount = () => {
......
......@@ -29,6 +29,9 @@ body {
table-layout: fixed;
word-wrap: break-word;
}
.button-0 {
width: 80px;
}
.button-1 {
width: 90px;
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -91,6 +91,7 @@ class FormCreate extends Component {
datarow.push(dataReferences[i].usr_dpt[0]);
datarow.push(dataReferences[i].subject[0]);
datarow.push(content);
datarow.push(dataReferences[i].user_id[0]);
this.state.dataReferences.push(datarow);
}
}
......@@ -204,6 +205,12 @@ class FormCreate extends Component {
render: function (data, type, row) {
return "<div>" + data + "</div>";
}
},
{
visible: false,
searchable: false,
orderable: false,
targets: 6
}
]
})
......@@ -225,7 +232,7 @@ class FormCreate extends Component {
tableReference.on("click", "a", function (e) {
e.preventDefault();
let data = tableReference.row($(this).parents("tr")).data();
window.open("http://10.10.86.48:3000/previewdocument?subject=" + data[1], "_blank");
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + data[1] + "&userid=" + data[6], "_blank");
})
} catch (err) {
console.log(err + "");
......@@ -758,7 +765,7 @@ class FormCreate extends Component {
method: 'POST',
body: JSON.stringify(postdataDokumen)
})
//Get All Data Document
//Get Data Document By Subject
let responseDataDocument = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/document/' + this.state.subject, { headers: { 'accept': 'application/xml' } })
parseString(responseDataDocument.data, function (err, result) {
doc_id = result.documentCollection.document[0].doc_id[0];
......@@ -860,7 +867,7 @@ class FormCreate extends Component {
"emailcc": JSON.parse(localStorage.getItem("dataLogin")).email[0],
"emailsend": dataApprover[0].EMail[0],
"message": "<p>Dengan hormat,</p> \
<p>Terdapat pengajuan dokumen dengan No." + this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode + " " + this.state.subject + " yang diajukan oleh " + JSON.parse(localStorage.getItem("dataLDAP"))["Full Name"] + ".<br /> Untuk review dan approval silahkan klik link berikut ini <a href='http://10.10.86.48:3000' target='_blank'>Link Dokumen</a></p> \
<p>Terdapat pengajuan dokumen dengan No." + this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode + " " + this.state.subject + " yang diajukan oleh " + JSON.parse(localStorage.getItem("dataLDAP"))["Full Name"] + ".<br /> Untuk review dan approval silahkan klik link berikut ini <a href='http://" + localStorage.getItem('host') + "' target='_blank'>Link Dokumen</a></p> \
<p>Terimakasih</p> \
<p>Regards,</p> \
<p>Admin</p><br /> \
......
......@@ -150,6 +150,9 @@ class FormCreateUpdateRole extends Component {
}
}
}
if (JSON.parse(localStorage.getItem("dataLogin")).email[0] == this.state.email && JSON.parse(localStorage.getItem("dataLogin")).user_role[0].includes("Compliance Officer")) {
isValidComplianceOfficer = true;
}
if (isValidComplianceOfficer) {
let dataEdit = {
"user_name": this.state.username,
......@@ -170,10 +173,10 @@ class FormCreateUpdateRole extends Component {
localStorage.setItem('dataLogin', JSON.stringify(tempData));
}
alert("User role has been successfully edited");
this.props.history.push("/manageuser")
this.props.history.push("/manageuser");
})
} else {
await this.setState({ submitForm: false });
await this.setState({ submitForm: false, validFormUser: true });
alert("A user with compliance officer roles already exist");
}
} catch (error) {
......
......@@ -40,7 +40,7 @@ class FormLogin extends Component {
key: '2ffb2a00a3abe029fdebae5e1d417ebcb04b7e103a0cd8b54763051cef08bc55'
}
})
if (responseDataLoginLDAP.data.code == 401) {
if (responseDataLoginLDAP.data.code == 401 || responseDataLoginLDAP.data == "") {
this.setState({ isLoginFailed: true, loggingIn: false, errMessage: "Username or Password is Invalid!" })
} else {
var parseString = require('xml2js').parseString;
......@@ -50,6 +50,7 @@ class FormLogin extends Component {
dataUser = result.user_dataCollection.user_data;
})
if (dataUser != undefined) {
localStorage.setItem('host', '10.10.88.12:3000');
localStorage.setItem('dataLogin', JSON.stringify(dataUser[0]));
let store = createStore(sessionReducer);
let todoAction = { type: "add_session", payload: responseDataLoginLDAP.data };
......
......@@ -53,7 +53,7 @@ class FormPublish extends Component {
try {
if (this.props.location.search != "") {
let values = queryString.parse(this.props.location.search);
if (values.subject != undefined && values.subject != "") {
if (values.subject != undefined && values.subject != "" && values.userid != undefined && values.userid != "") {
await this.setState({ subject: values.subject, subjectEdit: values.subject });
var parseString = require('xml2js').parseString;
let responseDataDocument = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/document/' + this.state.subject, { headers: { 'accept': 'application/xml' } })
......@@ -64,99 +64,104 @@ class FormPublish extends Component {
if (dataDocument != undefined) {
let isDocFound = false;
for (let m = 0; m < dataDocument.length; m++) {
let doc_id = dataDocument[m].doc_id[0];
let user_id = dataDocument[m].user_id[0];
let approver = dataDocument[m].approver[0];
let documentType = dataDocument[m].doc_type[0];
let documentCode = dataDocument[m].doc_code[0] + "";
let splitDocumentCode = documentCode.split("-");
let businessUnit = splitDocumentCode[0];
let revisionCode = splitDocumentCode[2];
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataRevision = responseDataRevision.data.revisionCollection.revision;
let responseDataAuditTrail = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/trailkey/' + doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataAuditTrail = responseDataAuditTrail.data.trailCollection.trail;
// Check is user valid to open the document
if (dataRevision[dataRevision.length - 1].status == "Waiting for Publish" || dataAuditTrail[dataAuditTrail.length - 1].trail_status == "Document Published") {
isDocFound = true;
let creator_name, creator_email;
let responseDataUser = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/userkeyid/' + user_id, { headers: { 'Content-Type': 'application/xml' } })
let dataUser = responseDataUser.data.user_dataCollection.user_data;
if (dataUser != undefined) {
creator_name = dataUser[0].user_name;
creator_email = dataUser[0].email;
} else {
creator_name = "";
creator_email = "";
}
if (dataRevision[dataRevision.length - 1].status == "Document Published") {
await this.setState({ statusPublish: true });
}
for (let i = 0; i < dataRevision.length; i++) {
let dataRevisionTable = {
"rev_code": dataRevision[i].rev_code,
"remark": dataRevision[i].remark,
"creator": dataUser[0].user_name,
"approval": dataRevision[i].approval
if (dataDocument[m].user_id[0] == values.userid) {
let doc_id = dataDocument[m].doc_id[0];
let user_id = dataDocument[m].user_id[0];
let approver = dataDocument[m].approver[0];
let documentType = dataDocument[m].doc_type[0];
let documentCode = dataDocument[m].doc_code[0] + "";
let splitDocumentCode = documentCode.split("-");
let businessUnit = splitDocumentCode[0];
let revisionCode = splitDocumentCode[2];
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataRevision = responseDataRevision.data.revisionCollection.revision;
let responseDataAuditTrail = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/trailkey/' + doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataAuditTrail = responseDataAuditTrail.data.trailCollection.trail;
// Check is user valid to open the document
if (dataRevision[dataRevision.length - 1].status == "Waiting for Publish" || dataAuditTrail[dataAuditTrail.length - 1].trail_status == "Document Published") {
isDocFound = true;
let creator_name, creator_email;
let responseDataUser = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/userkeyid/' + user_id, { headers: { 'Content-Type': 'application/xml' } })
let dataUser = responseDataUser.data.user_dataCollection.user_data;
if (dataUser != undefined) {
creator_name = dataUser[0].user_name;
creator_email = dataUser[0].email;
} else {
creator_name = "";
creator_email = "";
}
this.state.dataRevisionHistory.push(dataRevisionTable);
}
for (let i = 0; i < dataAuditTrail.length; i++) {
let dataTrail = {
"doc_code": dataAuditTrail[i].doc_code,
"date": dataAuditTrail[i].trail_date,
"role": dataAuditTrail[i].user_role,
"action": dataAuditTrail[i].action,
"status": dataAuditTrail[i].trail_status
if (dataRevision[dataRevision.length - 1].status == "Document Published") {
await this.setState({ statusPublish: true });
}
this.state.dataAuditTrail.push(dataTrail);
}
let revisionDate = dataDocument[m].rev_date[0];
let effectiveDate = dataDocument[m].eff_date[0];
let purpose = JSON.parse(dataDocument[m].information).purpose;
let scopes = JSON.parse(dataDocument[m].information).scopes;
let definitions = JSON.parse(dataDocument[m].information).definitions;
let selectReferences = JSON.parse(dataDocument[m].information).references;
if (revisionDate.includes("+00:00")) {
revisionDate = revisionDate.replace("+00:00", "");
}
if (dataRevision.length == 1) {
revisionDate = "-";
}
if (effectiveDate.includes("+00:00")) {
effectiveDate = effectiveDate.replace("+00:00", "");
}
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/contentkey/' + dataDocument[m].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
parseString(responseDataContent.data, function (err, result) {
dataContent = result.contentCollection.content;
})
if (dataContent != undefined && documentType != "FORM") {
for (let j = 0; j < dataContent.length; j++) {
let datarow = {
title: dataContent[j].cont_title[0],
description: dataContent[j].cont[0]
for (let i = 0; i < dataRevision.length; i++) {
let dataRevisionTable = {
"rev_code": dataRevision[i].rev_code,
"remark": dataRevision[i].remark,
"creator": dataUser[0].user_name,
"approval": dataRevision[i].approval
}
this.state.contents.push(datarow);
this.state.dataRevisionHistory.push(dataRevisionTable);
}
}
if (dataContent != undefined && documentType == "FORM") {
let datarow3 = {
cont_id: dataContent[0].cont_id[0],
title: dataContent[0].cont_title[0],
description: dataContent[0].cont[0]
let isShowRevisionDate = false;
for (let i = 0; i < dataAuditTrail.length; i++) {
if (dataAuditTrail[i].action == "Reject Document") {
isShowRevisionDate = true;
}
let dataTrail = {
"doc_code": dataAuditTrail[i].doc_code,
"date": dataAuditTrail[i].trail_date,
"role": dataAuditTrail[i].user_role,
"action": dataAuditTrail[i].action,
"status": dataAuditTrail[i].trail_status
}
this.state.dataAuditTrail.push(dataTrail);
}
let revisionDate = dataDocument[m].rev_date[0];
let effectiveDate = dataDocument[m].eff_date[0];
let purpose = JSON.parse(dataDocument[m].information).purpose;
let scopes = JSON.parse(dataDocument[m].information).scopes;
let definitions = JSON.parse(dataDocument[m].information).definitions;
let selectReferences = JSON.parse(dataDocument[m].information).references;
if (isShowRevisionDate == false) {
revisionDate = "-";
} else if (revisionDate.includes("+00:00")) {
revisionDate = revisionDate.replace("+00:00", "");
}
if (effectiveDate.includes("+00:00")) {
effectiveDate = effectiveDate.replace("+00:00", "");
}
this.state.contentsEdit.push(datarow3);
this.state.contentForm.cont_id = dataContent[0].cont_id[0];
this.state.contentForm.title = dataContent[0].cont_title[0];
this.state.contentForm.file = dataContent[0].cont[0];
this.setState({ contentForm: this.state.contentForm });
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/contentkey/' + dataDocument[m].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
parseString(responseDataContent.data, function (err, result) {
dataContent = result.contentCollection.content;
})
if (dataContent != undefined && documentType != "FORM") {
for (let j = 0; j < dataContent.length; j++) {
let datarow = {
title: dataContent[j].cont_title[0],
description: dataContent[j].cont[0]
}
this.state.contents.push(datarow);
}
}
if (dataContent != undefined && documentType == "FORM") {
let datarow3 = {
cont_id: dataContent[0].cont_id[0],
title: dataContent[0].cont_title[0],
description: dataContent[0].cont[0]
}
this.state.contentsEdit.push(datarow3);
this.state.contentForm.cont_id = dataContent[0].cont_id[0];
this.state.contentForm.title = dataContent[0].cont_title[0];
this.state.contentForm.file = dataContent[0].cont[0];
this.setState({ contentForm: this.state.contentForm });
}
await this.setState({
isFetched: true, doc_id: doc_id, user_id: user_id, creator_name: creator_name, creator_email: creator_email, approver: approver, documentType: documentType, businessUnit: businessUnit, revisionCode: revisionCode,
revisionDate: revisionDate, effectiveDate: effectiveDate, purpose: purpose, scopes: scopes, definitions: definitions, selectReferences: selectReferences
})
break;
}
await this.setState({
isFetched: true, doc_id: doc_id, user_id: user_id, creator_name: creator_name, creator_email: creator_email, approver: approver, documentType: documentType, businessUnit: businessUnit, revisionCode: revisionCode,
revisionDate: revisionDate, effectiveDate: effectiveDate, purpose: purpose, scopes: scopes, definitions: definitions, selectReferences: selectReferences
})
break;
}
}
if (!isDocFound) {
......@@ -177,10 +182,10 @@ class FormPublish extends Component {
}
}
handleBackPage = () => {
window.open("http://10.10.86.48:3000/yourdocument", "_self");
window.open("http://" + localStorage.getItem('host') + "/yourdocument", "_self");
}
handleClickPreview = () => {
window.open("http://10.10.86.48:3000/previewdocument?subject=" + this.state.subject, "_blank");
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + this.state.subject, "_blank");
}
handleClickPublish = async () => {
let labelPublish = "publish", actionPublish = "Publish Document", docStatusPublish = "Publish", tracking = "Document Published";;
......@@ -219,8 +224,9 @@ class FormPublish extends Component {
dataManagementRepresentative.push(dataRowManagementRepresentative);
}
}
let sendEmailPublish = "";
if (actionPublish == "Publish Document") {
let sendEmailPublish = this.state.creator_email;
sendEmailPublish = this.state.creator_email;
if (!sendEmailPublish.includes(JSON.parse(this.state.approver).Email)) {
if (sendEmailPublish != "") {
sendEmailPublish = sendEmailPublish + ", " + JSON.parse(this.state.approver).Email;
......@@ -241,7 +247,7 @@ class FormPublish extends Component {
"emailcc": JSON.parse(localStorage.getItem("dataLogin")).email[0],
"emailsend": sendEmailPublish,
"message": "<p>Dengan hormat,</p> \
<p>Dokumen dengan No." + this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode + " " + this.state.subject + " yang diajukan oleh " + this.state.creator_name + " telah dipublish.<br /> Untuk melihat dokumen, silahkan klik link berikut <a href='http://10.10.86.48:3000' target='_blank'>Link Dokumen</a></p> \
<p>Dokumen dengan No." + this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode + " " + this.state.subject + " yang diajukan oleh " + this.state.creator_name + " telah dipublish.<br /> Untuk melihat dokumen, silahkan klik link berikut <a href='http://" + localStorage.getItem('host') + "' target='_blank'>Link Dokumen</a></p> \
<p>Terimakasih</p> \
<p>Regards,</p> \
<p>Admin</p><br /> \
......@@ -252,6 +258,32 @@ class FormPublish extends Component {
method: 'POST',
body: JSON.stringify(postdataEmailAfterPublish)
})
} else if (actionPublish == "Publish Document") {
sendEmailPublish = this.state.creator_email;
if (!sendEmailPublish.includes(JSON.parse(this.state.approver).Email)) {
if (sendEmailPublish != "") {
sendEmailPublish = sendEmailPublish + ", " + JSON.parse(this.state.approver).Email;
} else {
sendEmailPublish = JSON.parse(this.state.approver).Email;
}
}
//Send Email Notification After UnPublish
let postdataEmailAfterUnpublish = {
"subject": "Dokumen " + this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode + "-" + this.state.subject + " Sudah Diunpublish",
"emailcc": "",
"emailsend": sendEmailPublish,
"message": "<p>Dengan hormat,</p> \
<p>Dokumen dengan No." + this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode + " " + this.state.subject + " yang diajukan oleh " + this.state.creator_name + " telah diunpublish oleh " + JSON.parse(localStorage.getItem("dataLogin")).user_name[0] + ".</p> \
<p>Terimakasih</p> \
<p>Regards,</p> \
<p>Admin</p><br /> \
<p><i>Ini adalah email otomatis, harap jangan me-reply ke alamat email ini</i></p>"
}
let responseSendEmailAfterPublish = await fetch(process.env.REACT_APP_MAIN_APIURL + '/email', {
headers: { 'Content-Type': 'application/json' },
method: 'POST',
body: JSON.stringify(postdataEmailAfterUnpublish)
})
}
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + this.state.doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataRevision = responseDataRevision.data.revisionCollection.revision;
......@@ -378,6 +410,13 @@ class FormPublish extends Component {
return "Publish";
}
}
showRemark = (remark) => {
if (remark == "") {
return "-"
} else {
return remark;
}
}
showApproval = (approval) => {
let approvalDocument, dataApproval = [];
if (approval != "") {
......@@ -502,7 +541,7 @@ class FormPublish extends Component {
<div className="card-body">
<div className="form-group row">
<div className="col-xl-3 col-lg-3 col-md-3 col-sm-3">
<Button color="primary" onClick={() => this.handleBackPage()}>&nbsp;{this.state.labelBackPage}&nbsp;</Button>
<Button color="primary" className="button-2" onClick={() => this.handleBackPage()}>{this.state.labelBackPage}</Button>
</div>
<div className="col-xl-9 col-lg-9 col-md-9 col-sm-9 text-right">
<Button color="primary" className="button-2" onClick={() => this.handleClickPreview()}>Preview</Button>&nbsp;
......@@ -631,7 +670,7 @@ class FormPublish extends Component {
return (
<tr key={index}>
<td>{dataRev.rev_code}</td>
<td>{dataRev.remark}</td>
<td>{this.showRemark(dataRev.remark)}</td>
<td>{dataRev.creator}</td>
<td>{this.showApproval(dataRev.approval)}</td>
</tr>
......
......@@ -22,7 +22,8 @@ class FormRevision extends Component {
isFetched: false,
labelChangePage: ["< Back", "Next >"],
page: [true, false, false, false, false],
validSubmitReject: false,
pageNotes: false,
validSubmitNotes: false,
validPage: [true, true, true],
optionScopes: ["All Department"],
pageScope: false,
......@@ -32,8 +33,10 @@ class FormRevision extends Component {
dataRevisionHistory: [],
dataAuditTrail: [],
headerContent: "Form Revision Document",
remark: "",
isValidClickNo: true,
notes: "",
doc_id: "",
doc_status: "",
user_id: "",
approver: "",
businessUnit: "",//doc
......@@ -65,7 +68,7 @@ class FormRevision extends Component {
try {
if (this.props.location.search != "") {
let values = queryString.parse(this.props.location.search);
if (values.subject != undefined && values.subject != "") {
if (values.subject != undefined && values.subject != "" && values.userid != undefined && values.userid != "") {
await this.setState({ subject: values.subject, subjectEdit: values.subject });
var parseString = require('xml2js').parseString;
let responseDataDocument = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/document/' + this.state.subject, { headers: { 'accept': 'application/xml' } })
......@@ -76,130 +79,141 @@ class FormRevision extends Component {
if (dataDocument != undefined) {
let isDocFound = false;
for (let m = 0; m < dataDocument.length; m++) {
let doc_id = dataDocument[m].doc_id[0];
let user_id = dataDocument[m].user_id[0];
let approver = dataDocument[m].approver[0];
let documentType = dataDocument[m].doc_type[0];
let documentCode = dataDocument[m].doc_code[0] + "";
let splitDocumentCode = documentCode.split("-");
let businessUnit = splitDocumentCode[0];
let revisionCode = splitDocumentCode[2];
// Check user id creator with user id document
if (user_id == JSON.parse(localStorage.getItem("dataLogin")).user_id[0]) {
isDocFound = true;
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataRevision = responseDataRevision.data.revisionCollection.revision;
let responseDataUser = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/userkeyid/' + user_id, { headers: { 'Content-Type': 'application/xml' } })
let dataUser = responseDataUser.data.user_dataCollection.user_data;
for (let i = 0; i < dataRevision.length; i++) {
let dataRevisionTable = {
"rev_code": dataRevision[i].rev_code,
"remark": dataRevision[i].remark,
"creator": dataUser[0].user_name,
"approval": dataRevision[i].approval
if (dataDocument[m].user_id[0] == values.userid) {
let doc_id = dataDocument[m].doc_id[0];
let doc_status = dataDocument[m].doc_status[0];
let user_id = dataDocument[m].user_id[0];
let approver = dataDocument[m].approver[0];
let documentType = dataDocument[m].doc_type[0];
let documentCode = dataDocument[m].doc_code[0] + "";
let splitDocumentCode = documentCode.split("-");
let businessUnit = splitDocumentCode[0];
let revisionCode = splitDocumentCode[2];
// Check user id creator with user id document
if (user_id == JSON.parse(localStorage.getItem("dataLogin")).user_id[0]) {
isDocFound = true;
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataRevision = responseDataRevision.data.revisionCollection.revision;
let responseDataUser = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/userkeyid/' + user_id, { headers: { 'Content-Type': 'application/xml' } })
let dataUser = responseDataUser.data.user_dataCollection.user_data;
for (let i = 0; i < dataRevision.length; i++) {
let dataRevisionTable = {
"rev_code": dataRevision[i].rev_code,
"remark": dataRevision[i].remark,
"creator": dataUser[0].user_name,
"approval": dataRevision[i].approval
}
this.state.dataRevisionHistory.push(dataRevisionTable);
}
this.state.dataRevisionHistory.push(dataRevisionTable);
}
let responseDataAuditTrail = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/trailkey/' + doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataAuditTrail = responseDataAuditTrail.data.trailCollection.trail;
for (let i = 0; i < dataAuditTrail.length; i++) {
let dataTrail = {
"doc_code": dataAuditTrail[i].doc_code,
"date": dataAuditTrail[i].trail_date,
"role": dataAuditTrail[i].user_role,
"action": dataAuditTrail[i].action,
"status": dataAuditTrail[i].trail_status
let notes = this.state.dataRevisionHistory[this.state.dataRevisionHistory.length - 1].remark;
let validSubmitNotes = false;
if (notes != "") {
validSubmitNotes = true;
}
this.state.dataAuditTrail.push(dataTrail);
}
let revisionDate = dataDocument[m].rev_date[0];
let effectiveDate = dataDocument[m].eff_date[0];
let purpose = JSON.parse(dataDocument[m].information).purpose;
let scopes = JSON.parse(dataDocument[m].information).scopes;
if (scopes[0] != "All Department") {
for (let l = 0; l < scopes.length; l++) {
this.state.optionScopes.push(scopes[l]);
this.state.copyScopes.push(scopes[l]);
let isShowRevisionDate = false;
let responseDataAuditTrail = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/trailkey/' + doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataAuditTrail = responseDataAuditTrail.data.trailCollection.trail;
for (let i = 0; i < dataAuditTrail.length; i++) {
if (dataAuditTrail[i].action == "Reject Document") {
isShowRevisionDate = true;
}
let dataTrail = {
"doc_code": dataAuditTrail[i].doc_code,
"date": dataAuditTrail[i].trail_date,
"role": dataAuditTrail[i].user_role,
"action": dataAuditTrail[i].action,
"status": dataAuditTrail[i].trail_status
}
this.state.dataAuditTrail.push(dataTrail);
}
}
let definitions = JSON.parse(dataDocument[m].information).definitions;
let selectReferences = JSON.parse(dataDocument[m].information).references;
for (let k = 0; k < selectReferences.length; k++) {
this.state.references.push(selectReferences[k]);
this.state.copyReferences.push(selectReferences[k]);
}
if (revisionDate.includes("+00:00")) {
revisionDate = revisionDate.replace("+00:00", "");
}
if (dataRevision.length == 1) {
revisionDate = "-";
}
if (effectiveDate.includes("+00:00")) {
effectiveDate = effectiveDate.replace("+00:00", "");
}
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/contentkey/' + dataDocument[m].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
parseString(responseDataContent.data, function (err, result) {
dataContent = result.contentCollection.content;
})
if (dataContent != undefined && documentType != "FORM") {
for (let j = 0; j < dataContent.length; j++) {
let datarow1 = {
cont_id: dataContent[j].cont_id[0],
title: dataContent[j].cont_title[0],
description: dataContent[j].cont[0]
let revisionDate = dataDocument[m].rev_date[0];
let effectiveDate = dataDocument[m].eff_date[0];
let purpose = JSON.parse(dataDocument[m].information).purpose;
let scopes = JSON.parse(dataDocument[m].information).scopes;
if (scopes[0] != "All Department") {
for (let l = 0; l < scopes.length; l++) {
this.state.optionScopes.push(scopes[l]);
this.state.copyScopes.push(scopes[l]);
}
let datarow2 = {
title: dataContent[j].cont_title[0],
description: dataContent[j].cont[0]
}
let definitions = JSON.parse(dataDocument[m].information).definitions;
let selectReferences = JSON.parse(dataDocument[m].information).references;
for (let k = 0; k < selectReferences.length; k++) {
this.state.references.push(selectReferences[k]);
this.state.copyReferences.push(selectReferences[k]);
}
if (isShowRevisionDate == false) {
revisionDate = "-";
} else if (revisionDate.includes("+00:00")) {
revisionDate = revisionDate.replace("+00:00", "");
}
if (effectiveDate.includes("+00:00")) {
effectiveDate = effectiveDate.replace("+00:00", "");
}
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/contentkey/' + dataDocument[m].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
parseString(responseDataContent.data, function (err, result) {
dataContent = result.contentCollection.content;
})
if (dataContent != undefined && documentType != "FORM") {
for (let j = 0; j < dataContent.length; j++) {
let datarow1 = {
cont_id: dataContent[j].cont_id[0],
title: dataContent[j].cont_title[0],
description: dataContent[j].cont[0]
}
let datarow2 = {
title: dataContent[j].cont_title[0],
description: dataContent[j].cont[0]
}
this.state.contentsEdit.push(datarow1);
this.state.contents.push(datarow2);
}
this.state.contentsEdit.push(datarow1);
this.state.contents.push(datarow2);
}
}
if (dataContent != undefined && documentType == "FORM") {
let datarow3 = {
cont_id: dataContent[0].cont_id[0],
title: dataContent[0].cont_title[0],
description: dataContent[0].cont[0]
if (dataContent != undefined && documentType == "FORM") {
let datarow3 = {
cont_id: dataContent[0].cont_id[0],
title: dataContent[0].cont_title[0],
description: dataContent[0].cont[0]
}
this.state.contentsEdit.push(datarow3);
this.state.contentForm.cont_id = dataContent[0].cont_id[0];
this.state.contentForm.title = dataContent[0].cont_title[0];
this.state.contentForm.file = dataContent[0].cont[0];
this.setState({ contentForm: this.state.contentForm });
}
this.state.contentsEdit.push(datarow3);
this.state.contentForm.cont_id = dataContent[0].cont_id[0];
this.state.contentForm.title = dataContent[0].cont_title[0];
this.state.contentForm.file = dataContent[0].cont[0];
this.setState({ contentForm: this.state.contentForm });
}
await this.setState({
isFetched: true, doc_id: doc_id, user_id: user_id, approver: approver, documentType: documentType, businessUnit: businessUnit, revisionCode: revisionCode,
revisionDate: revisionDate, effectiveDate: effectiveDate, purpose: purpose, scopes: scopes, definitions: definitions, selectReferences: selectReferences
})
if (this.state.scopes.length > 0) {
this.setState({ validAddScope: true });
}
if (this.state.selectReferences.length > 0) {
this.setState({ validAddReference: true });
}
let selectType = document.getElementById("documentType");
for (let i = 0; i < selectType.length; i++) {
if (selectType[i].value == this.state.documentType) {
selectType[i].selected = true;
break;
await this.setState({
isFetched: true, notes: notes, validSubmitNotes: validSubmitNotes, doc_id: doc_id, doc_status: doc_status, user_id: user_id, approver: approver, documentType: documentType, businessUnit: businessUnit, revisionCode: revisionCode,
revisionDate: revisionDate, effectiveDate: effectiveDate, purpose: purpose, scopes: scopes, definitions: definitions, selectReferences: selectReferences
})
if (this.state.scopes.length > 0) {
this.setState({ validAddScope: true });
}
}
let listScope = document.getElementsByName("listScope[]");
if (scopes[0] == "All Department") {
listScope[0].checked = true;
document.getElementById("btn-addScope").disabled = true;
} else {
for (let h = 1; h < listScope.length; h++) {
listScope[h].checked = true;
if (this.state.selectReferences.length > 0) {
this.setState({ validAddReference: true });
}
let selectType = document.getElementById("documentType");
for (let i = 0; i < selectType.length; i++) {
if (selectType[i].value == this.state.documentType) {
selectType[i].selected = true;
break;
}
}
let listScope = document.getElementsByName("listScope[]");
if (scopes[0] == "All Department") {
listScope[0].checked = true;
document.getElementById("btn-addScope").disabled = true;
} else {
for (let h = 1; h < listScope.length; h++) {
listScope[h].checked = true;
}
}
let listShowReference = document.getElementsByName("listShowReference[]");
for (let g = 0; g < listShowReference.length; g++) {
listShowReference[g].checked = true;
}
break;
}
let listShowReference = document.getElementsByName("listShowReference[]");
for (let g = 0; g < listShowReference.length; g++) {
listShowReference[g].checked = true;
}
break;
}
}
if (!isDocFound) {
......@@ -390,7 +404,7 @@ class FormRevision extends Component {
tableReference.on("click", "a", function (e) {
e.preventDefault();
let data = tableReference.row($(this).parents("tr")).data();
window.open("http://10.10.86.48:3000/previewdocument?subject=" + data[1], "_blank");
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + data[1], "_blank");
})
} catch (err) {
this.setState({ isFetched: true, fetchError: true });
......@@ -469,10 +483,113 @@ class FormRevision extends Component {
this.setState({ page: clonePage });
}
handleBackPage = () => {
window.open("http://10.10.86.48:3000/yourdocument", "_self");
window.open("http://" + localStorage.getItem('host') + "/yourdocument", "_self");
}
handleClickPreview = () => {
window.open("http://10.10.86.48:3000/previewdocument?subject=" + this.state.subject, "_blank");
window.open("http://" + localStorage.getItem('host') + "/previewdocument?subject=" + this.state.subject, "_blank");
}
changePageNotes = (e) => {
e.preventDefault();
let clonePage = this.state.page.slice();
let clonePageNotes = this.state.pageNotes;
clonePage[0] = !this.state.page[0];
clonePageNotes = !this.state.pageNotes;
this.setState({ page: clonePage, pageNotes: clonePageNotes });
}
handleChangeNotes = (e) => {
let notes = e.target.value;
this.setState({ notes: notes });
if (notes == "") {
this.setState({ validSubmitNotes: false });
} else {
this.setState({ validSubmitNotes: true });
}
}
handleSubmitNotes = async () => {
try {
await this.setState({ submitForm: true, validSubmitNotes: false });
var js2xmlparser = require('js2xmlparser');
var parseString = require('xml2js').parseString;
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + this.state.doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataRevision = responseDataRevision.data.revisionCollection.revision;
if (dataRevision != undefined) {
for (let i = 0; i < dataRevision.length; i++) {
if (dataRevision[i].rev_code == this.state.revisionCode) {
let dataUpdateRevision = {
"doc_id": this.state.doc_id,
"rev_code": this.state.revisionCode,
"remark": this.state.notes,
"user_id": this.state.user_id,
"status": dataRevision[i].status,
"approval": "",
"rev_id": dataRevision[i].rev_id
}
let putDataRevision = js2xmlparser.parse("_putrevisionupdate", dataUpdateRevision);
//Update Data Revision
let responseDataRevision = await axios.put(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionupdate/' + dataRevision[i].rev_id, putDataRevision, { headers: { 'Content-Type': 'text/xml' } })
this.state.dataRevisionHistory[this.state.dataRevisionHistory.length - 1].remark = this.state.notes;
await this.setState({ dataRevisionHistory: this.state.dataRevisionHistory, submitForm: false, validSubmitNotes: true });
alert("Notes has been successfully updated");
let clonePage = this.state.page.slice();
let clonePageNotes = this.state.pageNotes;
clonePage[0] = !this.state.page[0];
clonePageNotes = !this.state.pageNotes;
this.setState({ page: clonePage, pageNotes: clonePageNotes });
}
}
} else {
alert("Error: Data revision doesnot exist");
await this.setState({ submitForm: false, validSubmitNotes: true });
}
} catch (err) {
await this.setState({ submitForm: false, validSubmitNotes: true });
alert(err + "");
}
}
handleClickNo = async () => {
let isProceedNo = window.confirm("Are you sure document " + this.state.subject + " doesnot need to be revised?");
if (isProceedNo) {
try {
await this.setState({ submitForm: true, isValidClickNo: false });
var js2xmlparser = require('js2xmlparser');
var parseString = require('xml2js').parseString;
let responseDataAllUser = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/user', { headers: { 'accept': 'application/xml' } })
let dataAllUser;
parseString(responseDataAllUser.data, function (err, result) {
dataAllUser = result.user_dataCollection.user_data;
})
let emailComplianceOfficer = "";
for (let i = 0; i < dataAllUser.length; i++) {
if (dataAllUser[i].user_role[0].includes("Compliance Officer")) {
emailComplianceOfficer = dataAllUser[i].email[0];
break;
}
}
//Send Email Notification After Reviewed
let postdataEmailAfterUnpublish = {
"subject": "Dokumen " + this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode + "-" + this.state.subject + " Sudah Direview",
"emailcc": "",
"emailsend": emailComplianceOfficer,
"message": "<p>Dengan hormat,</p> \
<p>Dokumen dengan No." + this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode + " " + this.state.subject + " yang diajukan oleh " + this.state.creator_name + " telah direview dan tidak perlu direvisi.<br /> Untuk melihat dokumen, silahkan klik link berikut <a href='http://" + localStorage.getItem('host') + "' target='_blank'>Link Dokumen</a></p> \
<p>Terimakasih</p> \
<p>Regards,</p> \
<p>Admin</p><br /> \
<p><i>Ini adalah email otomatis, harap jangan me-reply ke alamat email ini</i></p>"
}
let responseSendEmailAfterPublish = await fetch(process.env.REACT_APP_MAIN_APIURL + '/email', {
headers: { 'Content-Type': 'application/json' },
method: 'POST',
body: JSON.stringify(postdataEmailAfterUnpublish)
})
await this.setState({ submitForm: false, isValidClickNo: true });
alert("Document has been successfully reviewed");
this.props.history.push("/yourdocument");
} catch (err) {
await this.setState({ submitForm: false, isValidClickNo: true });
alert(err + "");
}
}
}
//fungsi halaman 1
checkValidInputPage1 = () => {
......@@ -896,20 +1013,39 @@ class FormRevision extends Component {
var parseString = require('xml2js').parseString;
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + this.state.doc_id, { headers: { 'Content-Type': 'application/xml' } })
let dataRevision = responseDataRevision.data.revisionCollection.revision;
let rCode = this.state.revisionCode;
if (this.state.doc_status == "Publish") {
rCode = "R" + dataRevision.length;
}
for (let i = 0; i < dataRevision.length; i++) {
if (dataRevision[i].rev_code == this.state.revisionCode && dataRevision[i].status.includes("Document Rejected By")) {
if (dataRevision[i].rev_code == this.state.revisionCode && (dataRevision[i].status.includes("Document Rejected By") || this.state.doc_status == "Publish")) {
let tracking = "Waiting for Approval - " + JSON.parse(this.state.approver).EmpFullName;
let dataUpdateRevision = {
"doc_id": this.state.doc_id,
"rev_code": this.state.revisionCode,
"remark": dataRevision[i].remark,
"user_id": this.state.user_id,
"status": tracking,
"approval": dataRevision[i].approval,
"rev_id": dataRevision[i].rev_id
if (dataRevision[i].status.includes("Document Rejected")) {
let dataUpdateRevision = {
"doc_id": this.state.doc_id,
"rev_code": this.state.revisionCode,
"remark": dataRevision[i].remark,
"user_id": this.state.user_id,
"status": tracking,
"approval": dataRevision[i].approval,
"rev_id": dataRevision[i].rev_id
}
let putDataRevision = js2xmlparser.parse("_putrevisionupdate", dataUpdateRevision);
//Update Data Revision
let responseDataRevision = await axios.put(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionupdate/' + dataRevision[i].rev_id, putDataRevision, { headers: { 'Content-Type': 'text/xml' } })
} else if (this.state.doc_status == "Publish") {
let insertDataRevision = {
"doc_id": this.state.doc_id,
"rev_code": rCode,
"remark": "",
"user_id": this.state.user_id,
"status": tracking,
"approval": ""
}
let postDataRevision = js2xmlparser.parse("_postrevisioninsert", insertDataRevision);
//Insert Data Revision
let responseInsertRevision = await axios.post(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisioninsert', postDataRevision, { headers: { 'Content-Type': 'text/xml' } })
}
let putDataRevision = js2xmlparser.parse("_putrevisionupdate", dataUpdateRevision);
let responseDataRevision = await axios.put(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionupdate/' + dataRevision[i].rev_id, putDataRevision, { headers: { 'Content-Type': 'text/xml' } })
// Save trail
let today = new Date();
let monthInt = today.getMonth() + 1;
......@@ -969,7 +1105,7 @@ class FormRevision extends Component {
"user_role": "Creator",
"action": "Submit Revised Document",
"trail_status": tracking,
"doc_code": this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode
"doc_code": this.state.businessUnit + "-" + this.state.documentType + "-" + rCode
}
let postDataTrail = js2xmlparser.parse("_posttrailinsert", dataTrail);
let responseInsertTrail = await axios.post(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/trailinsert', postDataTrail, { headers: { 'Content-Type': 'text/xml' } })
......@@ -988,7 +1124,7 @@ class FormRevision extends Component {
this.setState({ revisionDate: this.state.revisionDate });
}
let putdataDokumen = {
"doc_code": this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode,
"doc_code": this.state.businessUnit + "-" + this.state.documentType + "-" + rCode,
"user_id": this.state.user_id,
"doc_type": this.state.documentType,
"rev_date": this.state.revisionDate,
......@@ -1087,7 +1223,11 @@ class FormRevision extends Component {
}
}
await this.setState({ submitForm: false });
alert("Document has been successfully updated");
if (this.state.doc_status == "Publish") {
alert("Document has been successfully reviewed");
} else {
alert("Document has been successfully updated");
}
this.props.history.push("/yourdocument");
} catch (error) {
this.state.validPage[2] = true;
......@@ -1095,6 +1235,13 @@ class FormRevision extends Component {
alert(error + "");
}
}
showRemark = (remark) => {
if (remark == "") {
return "-"
} else {
return remark;
}
}
showApproval = (approval) => {
let approvalDocument, dataApproval = [];
if (approval != "") {
......@@ -1142,7 +1289,7 @@ class FormRevision extends Component {
{({ getRootProps, getInputProps }) => (
<section>
<div {...getRootProps()} className="p-4 text-center" style={{ height: "250px", backgroundColor: "lightgrey", border: "1px solid black", borderRadius: "20px", borderStyle: "dashed" }}>
<input {...getInputProps()} accept=".doc,.docx,.xls,.xlsx"/>
<input {...getInputProps()} accept=".doc,.docx,.xls,.xlsx" />
{
this.state.contentForm.title == "" &&
<div>
......@@ -1446,22 +1593,55 @@ class FormRevision extends Component {
<div className="card-body">
<form>
<div hidden={!this.state.page[0]}>
<div className="form-group row">
<div className="col-xl-3 col-lg-3 col-md-3 col-sm-3">
<Button color="primary" onClick={() => this.handleBackPage()}>&nbsp;{this.state.labelChangePage[0]}&nbsp;</Button>
{
this.state.doc_status == "New" &&
<div className="form-group row">
<div className="col-xl-3 col-lg-3 col-md-3 col-sm-3">
<Button color="primary" className="button-2" onClick={() => this.handleBackPage()}>{this.state.labelChangePage[0]}</Button>
</div>
<div className="col-xl-9 col-lg-9 col-md-9 col-sm-9 text-right">
<Button color="primary" className="button-2" onClick={() => this.handleClickPreview()}>Preview</Button>
<a href="#" onClick={(e) => this.changePageNotes(e)}>
<SvgIcon className="float-right" style={{ width: "40px", height: "43px" }}>
<path fill="#000000" d="M19,3H14.82C14.25,1.44 12.53,0.64 11,1.2C10.14,1.5 9.5,2.16 9.18,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M12,3A1,1 0 0,1 13,4A1,1 0 0,1 12,5A1,1 0 0,1 11,4A1,1 0 0,1 12,3M7,7H17V5H19V19H5V5H7V7M17,11H7V9H17V11M15,15H7V13H15V15Z" />
</SvgIcon>
</a>
</div>
</div>
<div className="col-xl-9 col-lg-9 col-md-9 col-sm-9 text-right">
<Button color="primary" className="button-2" onClick={() => this.handleClickPreview()}>Preview</Button>
}
{
this.state.doc_status == "Publish" &&
<div>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<h5>Need to revision?</h5>
</div>
</div>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<Button color="success" className="button-0" onClick={(e) => this.changePage(e, "Next", 0)}>Yes</Button>&nbsp;
<Button color="danger" className="button-0" onClick={() => this.handleClickNo()} disabled={!this.state.isValidClickNo}>No&nbsp;
{
this.state.submitForm &&
<img src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" />
}
</Button>
</div>
</div>
</div>
</div>
}
<div className="container scrolling-wrapper col-xl-12 col-lg-12 col-md-12 col-sm-12 border" id="divToSave">
<div className="form-group row py-3">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<a href="#" onClick={(e) => this.changePage(e, "Next", 0)}>
<SvgIcon className="float-right">
<path fill="#000000" d="M5,3C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19H5V5H12V3H5M17.78,4C17.61,4 17.43,4.07 17.3,4.2L16.08,5.41L18.58,7.91L19.8,6.7C20.06,6.44 20.06,6 19.8,5.75L18.25,4.2C18.12,4.07 17.95,4 17.78,4M15.37,6.12L8,13.5V16H10.5L17.87,8.62L15.37,6.12Z" />
</SvgIcon>
</a>
{
this.state.doc_status == "New" &&
<a href="#" onClick={(e) => this.changePage(e, "Next", 0)}>
<SvgIcon className="float-right">
<path fill="#000000" d="M5,3C3.89,3 3,3.89 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V12H19V19H5V5H12V3H5M17.78,4C17.61,4 17.43,4.07 17.3,4.2L16.08,5.41L18.58,7.91L19.8,6.7C20.06,6.44 20.06,6 19.8,5.75L18.25,4.2C18.12,4.07 17.95,4 17.78,4M15.37,6.12L8,13.5V16H10.5L17.87,8.62L15.37,6.12Z" />
</SvgIcon>
</a>
}
</div>
</div>
<h1 className="text-center">{this.state.subject}</h1><br />
......@@ -1580,7 +1760,194 @@ class FormRevision extends Component {
return (
<tr key={index}>
<td>{dataRev.rev_code}</td>
<td>{dataRev.remark}</td>
<td>{this.showRemark(dataRev.remark)}</td>
<td>{dataRev.creator}</td>
<td>{this.showApproval(dataRev.approval)}</td>
</tr>
)
})
}
</tbody>
</table>
</div>
</div>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<h5>Audit Trail</h5>
</div>
</div>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<table className="my-table table table-striped table-hover">
<thead>
<tr>
<th className="col-xl-2 col-lg-2 col-md-2 col-sm-2" style={{ width: "200px" }}>Code</th>
<th className="col-xl-2 col-lg-2 col-md-2 col-sm-2" style={{ width: "200px" }}>Date</th>
<th className="col-xl-2 col-lg-2 col-md-2 col-sm-2" style={{ width: "120px" }}>Role</th>
<th className="col-xl-3 col-lg-3 col-md-3 col-sm-3">Action</th>
<th className="col-xl-3 col-lg-3 col-md-3 col-sm-3">Status</th>
</tr>
</thead>
<tbody>
{
this.state.dataAuditTrail.map((dataAudit, index) => {
return (
<tr key={index}>
<td>{dataAudit.doc_code}</td>
<td>{dataAudit.date}</td>
<td>{dataAudit.role}</td>
<td>{dataAudit.action}</td>
<td>{dataAudit.status}</td>
</tr>
)
})
}
</tbody>
</table>
</div>
</div>
</div>
<div hidden={!this.state.pageNotes}>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<h5>Edit Notes</h5>
</div>
</div>
<div className="form-group row">
<div className="col-xl-6 col-lg-6 col-md-6 col-sm-12">
<label>Preview document :</label>
<div className="container scrolling-wrapper col-lg-12 col-md-12 col-sm-12 col-xs-12 border">
<h2 className="text-center">{this.state.subject}</h2><br />
<div className="form-group row">
<label className="col-xl-4 col-lg-4 col-md-5 col-sm-4 control-label">Code</label>
<label className="col-xl-8 col-lg-8 col-md-7 col-sm-8">{": " + this.state.businessUnit + "-" + this.state.documentType + "-" + this.state.revisionCode}</label>
</div>
<div className="form-group row">
<label className="col-xl-4 col-lg-4 col-md-5 col-sm-4 control-label">Revision Date</label>
<label className="col-xl-8 col-lg-8 col-md-7 col-sm-8 control-label">{": " + this.state.revisionDate}</label>
</div>
<div className="form-group row">
<label className="col-xl-4 col-lg-4 col-md-5 col-sm-4 control-label">Effective Date</label>
<label className="col-xl-8 col-lg-8 col-md-7 col-sm-8 control-label">{": " + this.state.effectiveDate}</label>
</div>
<div className="form-group row">
<label className="col-xl-4 col-lg-4 col-md-5 col-sm-4 control-label">Purpose</label>
<label className="col-xl-8 col-lg-8 col-md-7 col-sm-8 control-label">
{
this.state.purpose.map((purpose, index) => {
return (
<div key={index}>
<label className="control-label">{(index + 1) + ". " + purpose}</label>
</div>
)
})
}
</label>
</div>
<div className="form-group row">
<label className="col-xl-4 col-lg-4 col-md-5 col-sm-4 control-label">Scope</label>
<label className="col-xl-8 col-lg-8 col-md-7 col-sm-8 control-label">
{
this.state.scopes.map((scope, index) => {
return (
<div key={index}>
<label className="control-label">{(index + 1) + ". " + scope}</label>
</div>
)
})
}
</label>
</div>
<div className="form-group row">
<label className="col-xl-4 col-lg-4 col-md-5 col-sm-4 control-label">Definition</label>
<label className="col-xl-8 col-lg-8 col-md-7 col-sm-8 control-label">{this.handleIfDefinitionEmpty()}
{
this.state.definitions.map((definition, index) => {
return (
<div key={index}>
<label className="control-label">{(index + 1) + ". " + definition}</label>
</div>
)
})
}
</label>
</div>
<div className="form-group row">
<label className="col-xl-4 col-lg-4 col-md-5 col-sm-4 control-label">Reference Document</label>
<label className="col-xl-8 col-lg-8 col-md-7 col-sm-8 control-label">{this.handleIfReferenceEmpty()}
{
this.state.references.map((reference, index) => {
return (
<div key={index}>
<label className="control-label">{(index + 1) + ". " + reference}</label>
</div>
)
})
}
</label>
</div>
<div className="form-group row">
<label className="col-xl-4 col-lg-4 col-md-5 col-sm-4 control-label">Content</label>
<label className="col-xl-8 col-lg-8 col-md-7 col-sm-8 control-label">
{
this.state.documentType != "FORM" &&
this.state.contents.map((content, index) => {
return (
<div key={index}>
<label className="control-label">{content.title}</label><br />
<div className="row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<div dangerouslySetInnerHTML={{ __html: content.description }}></div>
</div>
</div>
</div>
)
})
}
{
this.state.documentType == "FORM" &&
<a className="text-decoration-none" href={this.state.contentForm.file} download={this.state.contentForm.title}>{this.state.contentForm.title}</a>
}
</label>
</div>
</div>
</div>
<div className="col-xl-6 col-lg-6 col-md-6 col-sm-12">
<label>Give notes :</label>
<textarea className="col-xl-12 col-lg-12 col-md-12 col-sm-12 form-control" rows="20" onChange={(e) => this.handleChangeNotes(e)} value={this.state.notes} placeholder="Type your notes here..."></textarea><br />
<div className="text-right">
<Button color="primary" className="button-2" onClick={() => this.handleSubmitNotes()} disabled={!this.state.validSubmitNotes}>Submit&nbsp;
{
this.state.submitForm &&
<img src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" />
}
</Button>
</div>
</div>
</div>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<h5>Revision History Table</h5>
</div>
</div>
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<table className="my-table table table-striped table-hover">
<thead>
<tr>
<th className="col-xl-3 col-lg-3 col-md-3 col-sm-3">Code</th>
<th className="col-xl-3 col-lg-3 col-md-3 col-sm-3">Remark</th>
<th className="col-xl-3 col-lg-3 col-md-3 col-sm-3">Creator</th>
<th className="col-xl-3 col-lg-3 col-md-3 col-sm-3">Approval</th>
</tr>
</thead>
<tbody>
{
this.state.dataRevisionHistory.map((dataRev, index) => {
return (
<tr key={index}>
<td>{dataRev.rev_code}</td>
<td>{this.showRemark(dataRev.remark)}</td>
<td>{dataRev.creator}</td>
<td>{this.showApproval(dataRev.approval)}</td>
</tr>
......
......@@ -59,6 +59,7 @@ class Home extends Component {
datarow.push(new_effdate);
datarow.push(data[i].usr_dpt[0]);
datarow.push(content);
datarow.push(data[i].user_id[0]);
this.state.dataDocument.push(datarow);
}
}
......
......@@ -27,7 +27,7 @@ class Navbar1 extends Component {
e.preventDefault();
}
handleSignOut = () => {
localStorage.removeItem("user");
localStorage.removeItem("host");
localStorage.removeItem("dataLogin");
localStorage.removeItem("dataLDAP");
this.props.history.push("/");
......
......@@ -43,7 +43,7 @@ class PreviewDocument extends Component {
try {
if (this.props.location.search != "") {
let values = queryString.parse(this.props.location.search);
if (values.subject != undefined && values.subject != "") {
if (values.subject != undefined && values.subject != "" && values.userid != undefined && values.userid != "") {
await this.setState({ subject: values.subject })
var parseString = require('xml2js').parseString;
let responseDataDocument = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/document/' + this.state.subject, { headers: { 'accept': 'application/xml' } })
......@@ -52,78 +52,90 @@ class PreviewDocument extends Component {
dataDocument = result.documentCollection.document;
})
if (dataDocument != undefined) {
if (dataDocument[0].doc_status[0] == "Publish") {
let responseDataAuditTrail = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/trailkey/' + dataDocument[0].doc_id[0], { headers: { 'Content-Type': 'application/xml' } })
let dataAuditTrail = responseDataAuditTrail.data.trailCollection.trail;
for (let i = 0; i < dataAuditTrail.length; i++) {
if (dataAuditTrail[i].user_role == "Approver" && dataAuditTrail[i].action == "Approve Document") {
let status = dataAuditTrail[i].trail_status;
let complianceOfficer = status.replace("Waiting for Approval - ", "");
this.setState({ publisher: complianceOfficer });
for (let i = 0; i < dataDocument.length; i++) {
if (dataDocument[i].user_id[0] == values.userid) {
if (dataDocument[i].doc_status[0] == "Publish") {
let responseDataAuditTrail = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/trailkey/' + dataDocument[i].doc_id[0], { headers: { 'Content-Type': 'application/xml' } })
let dataAuditTrail = responseDataAuditTrail.data.trailCollection.trail;
for (let i = 0; i < dataAuditTrail.length; i++) {
if (dataAuditTrail[i].user_role == "Approver" && dataAuditTrail[i].action == "Approve Document") {
let status = dataAuditTrail[i].trail_status;
let complianceOfficer = status.replace("Waiting for Approval - ", "");
this.setState({ publisher: complianceOfficer });
}
}
}
}
}
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + dataDocument[0].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataRevision;
parseString(responseDataRevision.data, function (err, result) {
dataRevision = result.revisionCollection.revision;
})
let documentType = dataDocument[0].doc_type[0];
let documentCode = dataDocument[0].doc_code[0];
let revisionDate = this.convertToDateFormat(dataDocument[0].rev_date[0]);
let effectiveDate = this.convertToDateFormat(dataDocument[0].eff_date[0]);
let purpose = JSON.parse(dataDocument[0].information).purpose;
let scopes = JSON.parse(dataDocument[0].information).scopes;
let definitions = JSON.parse(dataDocument[0].information).definitions;
let references = JSON.parse(dataDocument[0].information).references;
if (revisionDate.includes("+00:00")) {
revisionDate = revisionDate.replace("+00:00", "");
}
if (dataRevision.length == 1) {
revisionDate = "-";
}
if (effectiveDate.includes("+00:00")) {
effectiveDate = effectiveDate.replace("+00:00", "");
}
this.setState({
documentType: documentType, documentCode: documentCode, revisionDate: revisionDate,
effectiveDate: effectiveDate, purpose: purpose, scopes: scopes, definitions: definitions, references: references
})
for (let i = 0; i < dataRevision.length; i++) {
let datarow1 = {
"revision_code": dataRevision[i].rev_code[0],
"remark": dataRevision[i].remark[0],
"approval": dataRevision[i].approval[0]
}
this.state.revisions.push(datarow1);
}
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/contentkey/' + dataDocument[0].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
parseString(responseDataContent.data, function (err, result) {
dataContent = result.contentCollection.content;
})
if (dataContent != undefined && documentType != "FORM") {
for (let j = 0; j < dataContent.length; j++) {
let datarow2 = {
title: dataContent[j].cont_title[0],
description: dataContent[j].cont[0]
let responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + dataDocument[i].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataRevision;
parseString(responseDataRevision.data, function (err, result) {
dataRevision = result.revisionCollection.revision;
})
let documentType = dataDocument[i].doc_type[0];
let documentCode = dataDocument[i].doc_code[0];
let revisionDate = this.convertToDateFormat(dataDocument[i].rev_date[0]);
let effectiveDate = this.convertToDateFormat(dataDocument[i].eff_date[0]);
let purpose = JSON.parse(dataDocument[i].information).purpose;
let scopes = JSON.parse(dataDocument[i].information).scopes;
let definitions = JSON.parse(dataDocument[i].information).definitions;
let references = JSON.parse(dataDocument[i].information).references;
let isShowRevisionDate = false;
let responseDataAuditTrail = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/trailkey/' + dataDocument[i].doc_id[0], { headers: { 'Content-Type': 'application/xml' } })
let dataAuditTrail = responseDataAuditTrail.data.trailCollection.trail;
for (let i = 0; i < dataAuditTrail.length; i++) {
if (dataAuditTrail[i].action == "Reject Document") {
isShowRevisionDate = true;
}
}
if (isShowRevisionDate == false) {
revisionDate = "-";
} else if (revisionDate.includes("+00:00")) {
revisionDate = revisionDate.replace("+00:00", "");
}
if (effectiveDate.includes("+00:00")) {
effectiveDate = effectiveDate.replace("+00:00", "");
}
this.setState({
documentType: documentType, documentCode: documentCode, revisionDate: revisionDate,
effectiveDate: effectiveDate, purpose: purpose, scopes: scopes, definitions: definitions, references: references
})
for (let i = 0; i < dataRevision.length; i++) {
let datarow1 = {
"revision_code": dataRevision[i].rev_code[0],
"remark": dataRevision[i].remark[0],
"approval": dataRevision[i].approval[0]
}
this.state.revisions.push(datarow1);
}
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/contentkey/' + dataDocument[i].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
parseString(responseDataContent.data, function (err, result) {
dataContent = result.contentCollection.content;
})
if (dataContent != undefined && documentType != "FORM") {
for (let j = 0; j < dataContent.length; j++) {
let datarow2 = {
title: dataContent[j].cont_title[0],
description: dataContent[j].cont[0]
}
this.state.contents.push(datarow2);
}
}
if (dataContent != undefined && documentType == "FORM") {
this.state.contentForm.cont_id = dataContent[0].cont_id[0];
this.state.contentForm.title = dataContent[0].cont_title[0];
this.state.contentForm.file = dataContent[0].cont[0];
this.setState({ contentForm: this.state.contentForm });
}
await this.setState({ isFetched: true });
let paper4 = document.getElementById("paper4");
if (paper4.clientHeight < 1123) {
let heightPaper4 = paper4.clientHeight + "px";
await this.setState({ isHeightPaper4Small: true, heightPaper4: heightPaper4 });
paper4.style.height = "1123px";
}
this.state.contents.push(datarow2);
break;
}
}
if (dataContent != undefined && documentType == "FORM") {
this.state.contentForm.cont_id = dataContent[0].cont_id[0];
this.state.contentForm.title = dataContent[0].cont_title[0];
this.state.contentForm.file = dataContent[0].cont[0];
this.setState({ contentForm: this.state.contentForm });
}
await this.setState({ isFetched: true });
let paper4 = document.getElementById("paper4");
if (paper4.clientHeight < 1123) {
let heightPaper4 = paper4.clientHeight + "px";
await this.setState({ isHeightPaper4Small: true, heightPaper4: heightPaper4 });
paper4.style.height = "1123px";
}
} else {
await this.setState({ isFetched: true, isDocumentNotFound: true });
}
......@@ -263,6 +275,13 @@ class PreviewDocument extends Component {
pdf.save(title + ".pdf");
await this.setState({ clickedDownload: false });
}
showRemark = (remark) => {
if (remark == "") {
return "-"
} else {
return remark;
}
}
showApproval = (approval) => {
let approvalDocument;
this.state.approvalDocument.splice(0, this.state.approvalDocument.length);
......@@ -441,7 +460,7 @@ class PreviewDocument extends Component {
return (
<tr key={index}>
<td>{revision.revision_code}</td>
<td>{revision.remark}</td>
<td>{this.showRemark(revision.remark)}</td>
<td>{this.showApproval(revision.approval)}</td>
</tr>
)
......@@ -559,7 +578,7 @@ class PreviewDocument extends Component {
this.state.documentType == "FORM" &&
<div className="row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<a className="text-decoration-none" href={this.state.contentForm.file} download={this.state.contentForm.title}>{this.state.contentForm.title}</a>
<a className="text-decoration-none text-dark" href={this.state.contentForm.file} download={this.state.contentForm.title}>{this.state.contentForm.title}</a>
</div>
</div>
}
......
......@@ -44,7 +44,7 @@ class YourDocument extends Component {
}
responseDataRevision = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/revisionkey/' + dataAllDocument[i].doc_id[0], { headers: { 'Content-Type': 'application/xml' } })
dataRevision = responseDataRevision.data.revisionCollection.revision;
if (dataAllDocument[i].user_id[0] == user_id && dataAllDocument[i].doc_status[0] == "New") {
if (dataAllDocument[i].user_id[0] == user_id && (dataAllDocument[i].doc_status[0] == "New" || dataAllDocument[i].doc_status[0] == "Publish")) {
let datarow = [];
let responseDataContent = await axios.get(process.env.REACT_APP_MAIN_APIURL + '/DocumentManagement/' + apiContent + '/' + dataAllDocument[i].doc_id[0], { headers: { 'accept': 'application/xml' } })
let dataContent;
......@@ -66,6 +66,7 @@ class YourDocument extends Component {
datarow.push(dataRevision[dataRevision.length - 1].status);
datarow.push(JSON.parse(localStorage.getItem("dataLDAP"))["Full Name"]);
datarow.push(content);
datarow.push(dataAllDocument[i].user_id);
this.state.dataDocument.push(datarow);
}
if ((dataRevision[dataRevision.length - 1].status.includes("Waiting for Approval") || dataRevision[dataRevision.length - 1].status.includes("Waiting for Approver") || dataRevision[dataRevision.length - 1].status.includes("Additional Approver")) && dataAllDocument[i].doc_status[0] == "New") {
......@@ -106,6 +107,7 @@ class YourDocument extends Component {
datarow2.push(dataRevision[dataRevision.length - 1].status);
datarow2.push(user_name);
datarow2.push(content);
datarow2.push(dataAllDocument[i].user_id);
this.state.dataApprovalDocument.push(datarow2);
}
}
......@@ -140,6 +142,7 @@ class YourDocument extends Component {
datarow3.push(dataRevision[dataRevision.length - 1].status);
datarow3.push(user_name2);
datarow3.push(content);
datarow3.push(dataAllDocument[i].user_id);
this.state.dataPublishDocument.push(datarow3);
}
if (dataAllDocument[i].doc_status[0] == "Unpublish" && JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Compliance Officer")) {
......@@ -173,6 +176,7 @@ class YourDocument extends Component {
datarow4.push(dataRevision[dataRevision.length - 1].status);
datarow4.push(user_name3);
datarow4.push(content);
datarow4.push(dataAllDocument[i].user_id);
this.state.dataExpiredDocument.push(datarow4);
}
}
......@@ -228,6 +232,7 @@ class YourDocument extends Component {
{
this.state.fetchStatus == true && JSON.parse(localStorage.getItem('dataLogin')).user_role[0].includes("Creator") && this.state.fetchError == false &&
<div>
<hr />
<div className="form-group row">
<div className="col-xl-12 col-lg-12 col-md-12 col-sm-12">
<h3>My Document</h3>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment