2374 |
23 Apr 14 |
nicklas |
var Xport = function() |
2374 |
23 Apr 14 |
nicklas |
2 |
{ |
2374 |
23 Apr 14 |
nicklas |
var xport = {}; |
2374 |
23 Apr 14 |
nicklas |
var previewTitle; |
2374 |
23 Apr 14 |
nicklas |
var previewList; |
2374 |
23 Apr 14 |
nicklas |
6 |
|
2374 |
23 Apr 14 |
nicklas |
xport.initPage = function() |
2374 |
23 Apr 14 |
nicklas |
8 |
{ |
2374 |
23 Apr 14 |
nicklas |
previewTitle = Doc.element('previewTitle'); |
2374 |
23 Apr 14 |
nicklas |
previewList = Doc.element('previewList'); |
2374 |
23 Apr 14 |
nicklas |
11 |
|
2374 |
23 Apr 14 |
nicklas |
Buttons.addClickHandler('goexport', xport.goExport); |
2374 |
23 Apr 14 |
nicklas |
Buttons.addClickHandler('gopreview', xport.goPreview); |
2603 |
27 Aug 14 |
nicklas |
14 |
|
2603 |
27 Aug 14 |
nicklas |
Doc.show('step-1'); |
2603 |
27 Aug 14 |
nicklas |
Doc.show('gopreview'); |
2603 |
27 Aug 14 |
nicklas |
Doc.show('goexport'); |
2374 |
23 Apr 14 |
nicklas |
18 |
} |
2374 |
23 Apr 14 |
nicklas |
19 |
|
2374 |
23 Apr 14 |
nicklas |
xport.goPreview = function() |
2374 |
23 Apr 14 |
nicklas |
21 |
{ |
2374 |
23 Apr 14 |
nicklas |
xport.doExport(true); |
2374 |
23 Apr 14 |
nicklas |
23 |
} |
2374 |
23 Apr 14 |
nicklas |
24 |
|
2374 |
23 Apr 14 |
nicklas |
xport.goExport = function() |
2374 |
23 Apr 14 |
nicklas |
26 |
{ |
2374 |
23 Apr 14 |
nicklas |
xport.doExport(false); |
2374 |
23 Apr 14 |
nicklas |
28 |
} |
2374 |
23 Apr 14 |
nicklas |
29 |
|
2374 |
23 Apr 14 |
nicklas |
xport.doExport = function(preview) |
2374 |
23 Apr 14 |
nicklas |
31 |
{ |
2374 |
23 Apr 14 |
nicklas |
var frm = document.forms['reggie']; |
2374 |
23 Apr 14 |
nicklas |
var url = '../Export.servlet?ID='+App.getSessionId(); |
2374 |
23 Apr 14 |
nicklas |
url += '&cmd=ExportINCA'; |
2374 |
23 Apr 14 |
nicklas |
url += '&time=' + frm.time.value; |
2374 |
23 Apr 14 |
nicklas |
url += '&exportSubtype=1'; |
2374 |
23 Apr 14 |
nicklas |
url += '&exportPatientId=1'; |
3904 |
29 Apr 16 |
nicklas |
url += '&progressbar=inca-export-progress'; |
2374 |
23 Apr 14 |
nicklas |
39 |
|
3904 |
29 Apr 16 |
nicklas |
Wizard.showLoadingAnimation('Working...', 'inca-export-progress'); |
3904 |
29 Apr 16 |
nicklas |
Doc.hide('navigation'); |
3904 |
29 Apr 16 |
nicklas |
Doc.hide('previewWrapper'); |
3904 |
29 Apr 16 |
nicklas |
43 |
|
2374 |
23 Apr 14 |
nicklas |
if (preview) |
2374 |
23 Apr 14 |
nicklas |
45 |
{ |
2603 |
27 Aug 14 |
nicklas |
url += '&preview=1'; |
2603 |
27 Aug 14 |
nicklas |
Wizard.asyncJsonRequest(url, xport.onPreviewLoaded); |
2374 |
23 Apr 14 |
nicklas |
48 |
} |
2374 |
23 Apr 14 |
nicklas |
else |
2374 |
23 Apr 14 |
nicklas |
50 |
{ |
2374 |
23 Apr 14 |
nicklas |
window.location = url; |
2374 |
23 Apr 14 |
nicklas |
52 |
} |
2374 |
23 Apr 14 |
nicklas |
53 |
} |
2374 |
23 Apr 14 |
nicklas |
54 |
|
2603 |
27 Aug 14 |
nicklas |
xport.onPreviewLoaded = function(response) |
2374 |
23 Apr 14 |
nicklas |
56 |
{ |
2603 |
27 Aug 14 |
nicklas |
Doc.show('navigation'); |
3904 |
29 Apr 16 |
nicklas |
58 |
|
2374 |
23 Apr 14 |
nicklas |
var frm = document.forms['reggie']; |
2603 |
27 Aug 14 |
nicklas |
var allLines = response.split('\n'); |
2374 |
23 Apr 14 |
nicklas |
var numCases = allLines.length - 2; // First line is a header line |
2374 |
23 Apr 14 |
nicklas |
62 |
|
2374 |
23 Apr 14 |
nicklas |
var html = '<tr><th>'+allLines[0].replace(/\t/g, '</th><th>')+'</th></tr>'; |
2374 |
23 Apr 14 |
nicklas |
for (var i = 1 ; i <= numCases; i++) |
2374 |
23 Apr 14 |
nicklas |
65 |
{ |
4717 |
28 Mar 18 |
nicklas |
html += '<tr><td>'+allLines[i].replace(/\t/g, '</td><td>')+'</td></tr>'; |
2374 |
23 Apr 14 |
nicklas |
67 |
} |
2374 |
23 Apr 14 |
nicklas |
68 |
|
2374 |
23 Apr 14 |
nicklas |
previewTitle.innerHTML = 'Sample dates - ' + frm.time[frm.time.selectedIndex].text + ' (' + numCases + ')'; |
2374 |
23 Apr 14 |
nicklas |
previewList.innerHTML = '<table>'+html+'</table>'; |
2374 |
23 Apr 14 |
nicklas |
Doc.show('previewWrapper'); |
2374 |
23 Apr 14 |
nicklas |
72 |
} |
2374 |
23 Apr 14 |
nicklas |
73 |
|
2374 |
23 Apr 14 |
nicklas |
return xport; |
2374 |
23 Apr 14 |
nicklas |
75 |
}(); |
2374 |
23 Apr 14 |
nicklas |
76 |
|
2374 |
23 Apr 14 |
nicklas |
Doc.onLoad(Xport.initPage); |
2374 |
23 Apr 14 |
nicklas |
78 |
|