| @@ -64,24 +64,46 @@ const Index = () => { | |||||
| dateFrom: input.dateFrom, | dateFrom: input.dateFrom, | ||||
| }, | }, | ||||
| onSuccess: (responseData) => { | onSuccess: (responseData) => { | ||||
| // console.log(responseData) | |||||
| const parser = new DOMParser(); | |||||
| const xmlDoc = parser.parseFromString(responseData, 'application/xml'); | |||||
| const filename = xmlDoc.querySelector('FileHeader').getAttribute('H_Filename'); | |||||
| const blob = new Blob([responseData], { type: 'application/xml' }); | |||||
| // Create a download link | |||||
| const link = document.createElement('a'); | |||||
| link.href = URL.createObjectURL(blob); | |||||
| link.download = filename+'.xml'; | |||||
| // Append the link to the document body | |||||
| document.body.appendChild(link); | |||||
| // Programmatically click the link to trigger the download | |||||
| link.click(); | |||||
| // Clean up the link | |||||
| document.body.removeChild(link); | |||||
| console.log(responseData) | |||||
| const parser = new DOMParser(); | |||||
| const xmlDoc = parser.parseFromString(responseData, 'application/xml'); | |||||
| // Get the DCBHeader element | |||||
| const dcbHeader = xmlDoc.querySelector("DCBHeader"); | |||||
| // Get the Receipt and Allocation elements | |||||
| const receiptElement = dcbHeader.querySelector("Receipt"); | |||||
| const allocationElement = dcbHeader.querySelector("Allocation"); | |||||
| const paymentMethodElements = Array.from(dcbHeader.querySelectorAll("PaymentMethod")); | |||||
| // Remove existing elements from DCBHeader | |||||
| dcbHeader.innerHTML = ""; | |||||
| dcbHeader.appendChild(receiptElement); | |||||
| dcbHeader.appendChild(allocationElement); | |||||
| if (paymentMethodElements) { | |||||
| paymentMethodElements.forEach((paymentMethodElement) => { | |||||
| dcbHeader.appendChild(paymentMethodElement); | |||||
| }); | |||||
| } | |||||
| const updatedXmlString = new XMLSerializer().serializeToString(xmlDoc); | |||||
| const filename = xmlDoc.querySelector('FileHeader').getAttribute('H_Filename'); | |||||
| console.log(updatedXmlString) | |||||
| const blob = new Blob([updatedXmlString], { type: 'application/xml' }); | |||||
| // Create a download link | |||||
| const link = document.createElement('a'); | |||||
| link.href = URL.createObjectURL(blob); | |||||
| link.download = filename+'.xml'; | |||||
| // Append the link to the document body | |||||
| document.body.appendChild(link); | |||||
| // Programmatically click the link to trigger the download | |||||
| link.click(); | |||||
| // Clean up the link | |||||
| document.body.removeChild(link); | |||||
| } | } | ||||
| }); | }); | ||||
| // open(UrlUtils.GEN_GFMIS_XML + "/today?online=true") | // open(UrlUtils.GEN_GFMIS_XML + "/today?online=true") | ||||