Commit e7d704ba by Jorem Magcawas

update reject return element

parent d2c4fdf5
var Dirfiles = <?php $arrFiles = array();
$path = './input';
$iterator = new FilesystemIterator($path);
foreach($iterator as $entry) {
$arrFiles[] = './input/' . $entry-> getFilename();
// $iter = new FilesystemIterator($entry);
// foreach($iter as $ent) {
// $arrFiles[] = './input/' . $entry-> getFilename() . '/' . $ent-> getFilename();
// }
}
echo json_encode($arrFiles);
?>
\ No newline at end of file
......@@ -209,9 +209,6 @@
</body>
<!--body onload-->
<script src='dir.php'></script>
<script src="./src/BPO/bpoService.js"></script>
<script src="./src/BPO/getElement.js"></script>
<script src="./src/BPO/returnElement.js"></script>
......
......@@ -170,7 +170,7 @@ async function createOutputXml(fields, metrics, doctype, section) {
"projCode": PROJECT_CODE,
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": "_SCHEMA",
"schema": SCHEMA_FILE,
"totalRec": Dirfiles.length,
"maxRec": "1",
"totalKeystroke": metrics[0],
......
......@@ -23,22 +23,19 @@ createRejectWindow(); //window for reason rejecting element
var rejectButton = document.getElementById('reject');
rejectButton.onclick = function () {
// let screenMain = document.getElementById('parent_Window');
// screenMain.style.display = 'block';
// rejectButton.disabled = true;
rejectElement();
const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click();
let screenMain = document.getElementById('parent_Window');
screenMain.style.display = 'block';
rejectButton.disabled = true;
//rejectElement();
//const fieldForm = document.getElementById("fields");
//fieldForm.querySelector('input[type="submit"]').click();
};
window.addEventListener('keydown', function(e) {
if (e.ctrlKey == true && e.keyCode == 69){
// let screenMain = document.getElementById('parent_Window');
// screenMain.style.display = 'block';
// rejectButton.disabled = true;
rejectElement();
const fieldForm = document.getElementById("fields");
fieldForm.querySelector('input[type="submit"]').click();
let screenMain = document.getElementById('parent_Window');
screenMain.style.display = 'block';
rejectButton.disabled = true;
}
});
......@@ -47,28 +44,42 @@ function createRejectWindow(){
let screenMain = document.createElement('div');
screenMain.id = 'parent_Window';
screenMain.style.display = 'none';
document.body.appendChild(screenMain);
document.body.appendChild(screenMain);
//checkbox&label
screenMain.appendChild(checkLabelComponent('Reason 1','check1'));
screenMain.appendChild(checkLabelComponent('Reason 2','check2'));
screenMain.appendChild(checkLabelComponent('Reason 3','check3'));
screenMain.appendChild(checkLabelComponent('Reason 4','check4'));
screenMain.appendChild(checkLabelComponent('Others','check5'));
screenMain.appendChild(checkLabelComponent('Reason 1','Reason 1','check1'));
screenMain.appendChild(checkLabelComponent('Reason 2','Reason 1','check2'));
screenMain.appendChild(checkLabelComponent('Reason 3','Reason 1','check3'));
screenMain.appendChild(checkLabelComponent('Reason 4','Reason 1','check4'));
screenMain.appendChild(checkLabelComponent('Others','','check5'));
screenMain.appendChild(createMessageBox('text-area'));
screenMain.appendChild(okCancelButton());
//set radio button text area value
let radioMessage = document.getElementById('check5');
let text = document.getElementById('text-area');
radioMessage.value = text.value;
}
function checkLabelComponent(textLabel,checkboxId){
function checkLabelComponent(textLabel,inputval,checkboxId){
let checkBoxCont = document.createElement('div');
checkBoxCont.id = 'checkBoxCont';
let inp = document.createElement("input");
inp.id = checkboxId;
inp.setAttribute('type', 'checkbox');
inp.name = checkboxId;
inp.value = textLabel;
inp.setAttribute('type', 'radio');
inp.name = "rejectRadio";
inp.value = inputval;
inp.style.order = 1;
inp.style.marginTop = 0;
if(checkboxId == 'check1'){
inp.checked = true;
}
var newlabel = document.createElement("Label");
newlabel.setAttribute("for", checkboxId);
......@@ -82,21 +93,33 @@ function checkLabelComponent(textLabel,checkboxId){
}
function okCancelButton(){
let screenMain = document.getElementById('parent_Window');
let buttonCont = document.createElement('div');
buttonCont.id = 'okCancelCont';
let okButton = document.createElement('button');
//okButton.setAttribute('type', 'submit');
okButton.id = 'reject_ok';
okButton.innerHTML = 'ok'
okButton.innerHTML = 'ok';
okButton.onclick = function () {
saveExceptionToXml();//save xml
rejectElement();//reject on bpo
screenMain.style.display = 'none';
rejectButton.disabled = false;
return false;
}
let cancelButton = document.createElement('button');
cancelButton.id = 'reject_Cancel';
cancelButton.innerHTML = 'cancel';
cancelButton.onclick = function () {
let screenMain = document.getElementById('parent_Window');
screenMain.style.display = 'none';
rejectButton.disabled = false;
return false;
}
buttonCont.appendChild(okButton);
......@@ -106,13 +129,87 @@ function okCancelButton(){
}
function saveExceptionToXml(){
var selected = document.querySelector('input[name="rejectRadio"]:checked').value;
var elementId = sessionStorage.getItem("element_id");
let xmlData = {
"projCode": PROJECT_CODE,
"userId": sessionStorage.getItem("user_id"),
"elementId": elementId,
"schema": SCHEMA_FILE,
"totalRec": Dirfiles.length,
"maxRec": "1",
"totalKeystroke": 0,
"procTime": "",
"procDuration": 0,
"eob": "",
"exceptionRemark": selected,
"recordNo": "1",
"totalSubRec": "1",
"maxSubRec": "1",
"imageName": File_Path,
"subRecordNo": "1",
"eor": "",
"fields": {},
"outputDir": sessionStorage.getItem("element_file_loc") + "/" + (ENCODING_PASS == "PASS1" ? elementId + ".DTA" : elementId + ".DTB"),
"doctype": "",
"section": ""
}
updateXMLException(xmlData);
return false;
}
function createMessageBox(id){
var mssgBox = document.createElement('textarea');
mssgBox.name = "post";
mssgBox.name = "rejectRadio";
mssgBox.maxLength = "1000";
mssgBox.cols = "24";
mssgBox.rows = "5";
mssgBox.id = id;
mssgBox.disabled = true;
mssgBox.onkeyup = function () {
let radioFive = document.getElementById('check5');
radioFive.value = mssgBox.value;
}
return mssgBox;
}
var addressOther = document.querySelectorAll('input[name="rejectRadio"]');
var addressField = document.getElementById('text-area');
var tempAddress = "";
for(var i = 0; i < addressOther.length; i++) {
addressOther[i].addEventListener("change", addressHandler);
}
function addressHandler() {
if(this.id == "check5") {
addressField.disabled = false;
addressField.value = tempAddress;
} else {
tempAddress = addressField.value;
addressField.value = "";
addressField.disabled = true;
}
}
async function updateXMLException(xmlData){
let response = await fetch('http://35.169.23.0:8080/WebGde/svc/gfs-rest/update-exception', {
method: "POST",
headers: {
'Content-Type':'application/json'
},
body: JSON.stringify(xmlData)
});
if (response.status == 200) {
alert("Exception Updated");
}
else{
alert(`Error ${response.status}: Xml Update`);
}
return false;
}
\ No newline at end of file
......@@ -204,5 +204,28 @@ public class GDEWebServices {
}
return Response.ok("Success").build();
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/update-exception")
public Response updateException(XMLContents xml) {
try {
File file = new File(xml.getOutputDir());
if(file.exists()) {
XMLUtil.updateExceptionRmrk(xml);
}else {
XMLUtil.generateXML(xml);
}
} catch (Exception e) {
e.printStackTrace();
return Response.status(500).entity("Failed").build();
// return Response.status(500).entity("Fail").build();
}
return Response.ok("Success").build();
}
}
......@@ -226,4 +226,29 @@ public class XMLUtil {
StreamResult result = new StreamResult(xml.getOutputDir());
transformer.transform(source, result);
}
public static void updateExceptionRmrk(XMLContents xml)
throws ParserConfigurationException,SAXException, IOException, TransformerException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xml.getOutputDir());
document.getElementsByTagName("exception_remark").item(0).setTextContent(xml.getExceptionRemark());
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.STANDALONE, "no");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
removeEmptyText(document);
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(xml.getOutputDir());
transformer.transform(source, result);
}
}
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