3786 |
17 Mar 16 |
olle |
var Iport = function() |
3786 |
17 Mar 16 |
olle |
2 |
{ |
3786 |
17 Mar 16 |
olle |
var iport = {}; |
3786 |
17 Mar 16 |
olle |
var debug = 0; |
3786 |
17 Mar 16 |
olle |
5 |
|
5270 |
29 Jan 19 |
nicklas |
var importFileIsValid = false; |
5270 |
29 Jan 19 |
nicklas |
var checkType; |
3786 |
17 Mar 16 |
olle |
8 |
|
3786 |
17 Mar 16 |
olle |
iport.initPage = function() |
3786 |
17 Mar 16 |
olle |
10 |
{ |
3786 |
17 Mar 16 |
olle |
// Step 1 |
3786 |
17 Mar 16 |
olle |
Events.addEventHandler('step-1', 'wizard-validate', iport.validateStep1); |
5270 |
29 Jan 19 |
nicklas |
Events.addEventHandler('exportDate', 'blur', Wizard.validateDate); |
3786 |
17 Mar 16 |
olle |
Events.addEventHandler('importfile', 'change', iport.importFileOnChange); |
3786 |
17 Mar 16 |
olle |
15 |
|
5270 |
29 Jan 19 |
nicklas |
// Step 2 |
5270 |
29 Jan 19 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', iport.initializeStep2); |
5270 |
29 Jan 19 |
nicklas |
18 |
|
3786 |
17 Mar 16 |
olle |
// Navigation |
5270 |
29 Jan 19 |
nicklas |
Buttons.addClickHandler('fullcheck', iport.startCheck); |
5270 |
29 Jan 19 |
nicklas |
Buttons.addClickHandler('simplecheck', iport.startCheck); |
3786 |
17 Mar 16 |
olle |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
3786 |
17 Mar 16 |
olle |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
3786 |
17 Mar 16 |
olle |
Buttons.addClickHandler('goimport', Wizard.goRegister); |
3786 |
17 Mar 16 |
olle |
Buttons.addClickHandler('downloadreportfile', iport.downloadReportFile); |
5275 |
31 Jan 19 |
nicklas |
Buttons.addClickHandler('downloadoutputfile', iport.downloadReportFile); |
3786 |
17 Mar 16 |
olle |
27 |
|
3786 |
17 Mar 16 |
olle |
// Final registration |
3786 |
17 Mar 16 |
olle |
Events.addEventHandler('wizard', 'wizard-submit', iport.submit); |
3786 |
17 Mar 16 |
olle |
30 |
|
3786 |
17 Mar 16 |
olle |
Doc.show('step-1'); |
5270 |
29 Jan 19 |
nicklas |
Doc.show('fullcheck'); |
3786 |
17 Mar 16 |
olle |
Doc.show('simplecheck'); |
5270 |
29 Jan 19 |
nicklas |
34 |
|
5270 |
29 Jan 19 |
nicklas |
Doc.element('exportDate').focus(); |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('importfile', 'invalid', 'Please select a file!'); |
5270 |
29 Jan 19 |
nicklas |
iport.importFileOnChange(); |
3786 |
17 Mar 16 |
olle |
38 |
} |
3786 |
17 Mar 16 |
olle |
39 |
|
5270 |
29 Jan 19 |
nicklas |
iport.startCheck = function(event) |
5270 |
29 Jan 19 |
nicklas |
41 |
{ |
5270 |
29 Jan 19 |
nicklas |
checkType = event.currentTarget.id; |
5273 |
31 Jan 19 |
nicklas |
Doc.hide('downloadreportfile'); |
5270 |
29 Jan 19 |
nicklas |
Wizard.setCurrentStep(1); |
5270 |
29 Jan 19 |
nicklas |
Doc.addClass('step-2', 'disabled'); |
5270 |
29 Jan 19 |
nicklas |
Wizard.goNext(); |
5270 |
29 Jan 19 |
nicklas |
47 |
} |
5270 |
29 Jan 19 |
nicklas |
48 |
|
3786 |
17 Mar 16 |
olle |
iport.validateStep1 = function(event) |
3786 |
17 Mar 16 |
olle |
50 |
{ |
5270 |
29 Jan 19 |
nicklas |
var valid = importFileIsValid; |
5270 |
29 Jan 19 |
nicklas |
valid &= Wizard.isValid('exportDate'); |
3786 |
17 Mar 16 |
olle |
if (!valid) event.preventDefault(); |
3786 |
17 Mar 16 |
olle |
54 |
} |
3786 |
17 Mar 16 |
olle |
55 |
|
3786 |
17 Mar 16 |
olle |
iport.importFileOnChange = function() |
3786 |
17 Mar 16 |
olle |
57 |
{ |
5270 |
29 Jan 19 |
nicklas |
importFileIsValid = false; |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('importfile'); |
5270 |
29 Jan 19 |
nicklas |
60 |
|
3786 |
17 Mar 16 |
olle |
var frm = document.forms['reggie']; |
3786 |
17 Mar 16 |
olle |
var files = frm.importfile.files; |
3786 |
17 Mar 16 |
olle |
63 |
|
5270 |
29 Jan 19 |
nicklas |
if (files.length == 1) |
3786 |
17 Mar 16 |
olle |
65 |
{ |
5270 |
29 Jan 19 |
nicklas |
importFileIsValid = true; |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('importfile', 'valid'); |
3786 |
17 Mar 16 |
olle |
68 |
} |
3786 |
17 Mar 16 |
olle |
else |
3786 |
17 Mar 16 |
olle |
70 |
{ |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('importfile', 'invalid', 'A file must be selected.'); |
3786 |
17 Mar 16 |
olle |
72 |
} |
3786 |
17 Mar 16 |
olle |
73 |
} |
3786 |
17 Mar 16 |
olle |
74 |
|
3786 |
17 Mar 16 |
olle |
75 |
|
5270 |
29 Jan 19 |
nicklas |
iport.initializeStep2 = function() |
3786 |
17 Mar 16 |
olle |
77 |
{ |
5279 |
05 Feb 19 |
nicklas |
Doc.hide('explainFileCheck'); |
3786 |
17 Mar 16 |
olle |
var frm = document.forms['reggie']; |
3786 |
17 Mar 16 |
olle |
var exportDate = frm.exportDate.value; |
3786 |
17 Mar 16 |
olle |
81 |
|
3786 |
17 Mar 16 |
olle |
var formData = new FormData(); |
3786 |
17 Mar 16 |
olle |
var files = frm.importfile.files; |
3786 |
17 Mar 16 |
olle |
for (var i = 0; i < files.length; i++) |
3786 |
17 Mar 16 |
olle |
85 |
{ |
3786 |
17 Mar 16 |
olle |
var file = files[i]; |
3786 |
17 Mar 16 |
olle |
formData.append('incafiles[]', file, file.name); |
3786 |
17 Mar 16 |
olle |
88 |
} |
3786 |
17 Mar 16 |
olle |
89 |
|
3786 |
17 Mar 16 |
olle |
var url = '../Inca.servlet?ID='+App.getSessionId(); |
3786 |
17 Mar 16 |
olle |
url += '&cmd=ImportInca'; |
3786 |
17 Mar 16 |
olle |
url += '&exportdate='+encodeURIComponent(exportDate); |
5270 |
29 Jan 19 |
nicklas |
url += '&checkType=' + checkType; |
3786 |
17 Mar 16 |
olle |
94 |
|
3786 |
17 Mar 16 |
olle |
// POST |
3920 |
03 May 16 |
olle |
Wizard.showLoadingAnimation('Checking INCA data...', 'inca-import-progress'); |
5270 |
29 Jan 19 |
nicklas |
Wizard.asyncJsonRequest(url, iport.checkCompleted, 'POST', formData); |
3786 |
17 Mar 16 |
olle |
98 |
} |
5270 |
29 Jan 19 |
nicklas |
99 |
|
5270 |
29 Jan 19 |
nicklas |
iport.checkCompleted = function(response) |
3786 |
17 Mar 16 |
olle |
101 |
{ |
5263 |
24 Jan 19 |
nicklas |
var fileInfo = response.fileInfo; |
5263 |
24 Jan 19 |
nicklas |
var headers = fileInfo.headers; |
5263 |
24 Jan 19 |
nicklas |
104 |
|
5270 |
29 Jan 19 |
nicklas |
var checkType = response.checkType; |
5270 |
29 Jan 19 |
nicklas |
var fileCanBeImported = true; |
5263 |
24 Jan 19 |
nicklas |
107 |
|
5263 |
24 Jan 19 |
nicklas |
Doc.element('filename').innerHTML = Strings.encodeTags(fileInfo.filename); |
5263 |
24 Jan 19 |
nicklas |
Doc.element('isFollowUp').innerHTML = fileInfo.isFollowUp ? 'Yes' : 'No'; |
5263 |
24 Jan 19 |
nicklas |
Doc.element('headerCount').innerHTML = headers.count; |
5263 |
24 Jan 19 |
nicklas |
111 |
|
5263 |
24 Jan 19 |
nicklas |
Doc.element('headerMissing').innerHTML = headers.missing; |
5263 |
24 Jan 19 |
nicklas |
if (headers.missing > 0) |
5263 |
24 Jan 19 |
nicklas |
114 |
{ |
5270 |
29 Jan 19 |
nicklas |
fileCanBeImported = false; |
5263 |
24 Jan 19 |
nicklas |
Wizard.setInputStatus('headerMissing', 'invalid', 'One ore more required headers are missing: <b>' + Strings.encodeTags(headers.missingNames.join(', ')) + '</b>'); |
5263 |
24 Jan 19 |
nicklas |
117 |
} |
5274 |
31 Jan 19 |
nicklas |
else |
5274 |
31 Jan 19 |
nicklas |
119 |
{ |
5274 |
31 Jan 19 |
nicklas |
Wizard.setInputStatus('headerMissing', 'valid'); |
5274 |
31 Jan 19 |
nicklas |
121 |
} |
5274 |
31 Jan 19 |
nicklas |
122 |
|
5263 |
24 Jan 19 |
nicklas |
Doc.element('headerDuplicates').innerHTML = headers.duplicates; |
5263 |
24 Jan 19 |
nicklas |
if (headers.duplicates > 0) |
5263 |
24 Jan 19 |
nicklas |
125 |
{ |
5270 |
29 Jan 19 |
nicklas |
fileCanBeImported = false; |
5263 |
24 Jan 19 |
nicklas |
Wizard.setInputStatus('headerDuplicates', 'invalid', 'Duplicate headers must be removed before the file can be imported: <b>' + Strings.encodeTags(headers.duplicateNames.join(', ')) + '</b>'); |
5263 |
24 Jan 19 |
nicklas |
128 |
} |
5274 |
31 Jan 19 |
nicklas |
else |
5274 |
31 Jan 19 |
nicklas |
130 |
{ |
5274 |
31 Jan 19 |
nicklas |
Wizard.setInputStatus('headerDuplicates', 'valid'); |
5274 |
31 Jan 19 |
nicklas |
132 |
} |
5263 |
24 Jan 19 |
nicklas |
133 |
|
5263 |
24 Jan 19 |
nicklas |
Doc.element('headerUnknown').innerHTML = headers.unknown; |
5263 |
24 Jan 19 |
nicklas |
if (headers.unknown > 0) |
5263 |
24 Jan 19 |
nicklas |
136 |
{ |
5274 |
31 Jan 19 |
nicklas |
Wizard.setInputStatus('headerUnknown', 'warning', 'Data in columns that can\'t be mapped to INCA annotations is ignored.'); |
5263 |
24 Jan 19 |
nicklas |
138 |
} |
5263 |
24 Jan 19 |
nicklas |
139 |
|
5274 |
31 Jan 19 |
nicklas |
Doc.element('headerMapped').innerHTML = headers.mapped; |
5274 |
31 Jan 19 |
nicklas |
if (headers.mapped == 0) |
5274 |
31 Jan 19 |
nicklas |
142 |
{ |
5274 |
31 Jan 19 |
nicklas |
fileCanBeImported = false; |
5274 |
31 Jan 19 |
nicklas |
Wizard.setInputStatus('headerMapped', 'invalid', 'No columns could be mapped to INCA annotations.'); |
5274 |
31 Jan 19 |
nicklas |
145 |
} |
5274 |
31 Jan 19 |
nicklas |
else |
5274 |
31 Jan 19 |
nicklas |
147 |
{ |
5274 |
31 Jan 19 |
nicklas |
Wizard.setInputStatus('headerMapped', 'valid', 'Existing INCA annotations that are found in the file.'); |
5274 |
31 Jan 19 |
nicklas |
149 |
} |
5274 |
31 Jan 19 |
nicklas |
150 |
|
5268 |
25 Jan 19 |
nicklas |
Doc.element('headerUnmapped').innerHTML = headers.unmapped; |
5268 |
25 Jan 19 |
nicklas |
if (headers.unmapped > 0) |
5268 |
25 Jan 19 |
nicklas |
153 |
{ |
5274 |
31 Jan 19 |
nicklas |
Wizard.setInputStatus('headerUnmapped', 'warning', 'Existing INCA annotations that are not found in the file.'); |
5268 |
25 Jan 19 |
nicklas |
155 |
} |
5268 |
25 Jan 19 |
nicklas |
156 |
|
5270 |
29 Jan 19 |
nicklas |
var importLineCount = fileInfo.data.count - fileInfo.data.totalExcluded; |
5263 |
24 Jan 19 |
nicklas |
Doc.element('lineCount').innerHTML = fileInfo.data.count; |
5270 |
29 Jan 19 |
nicklas |
Doc.element('importLineCount').innerHTML = importLineCount + (checkType == 'simplecheck' ? ' *' : ''); |
5270 |
29 Jan 19 |
nicklas |
Doc.element('totalExcluded').innerHTML = fileInfo.data.totalExcluded; |
5270 |
29 Jan 19 |
nicklas |
if (fileInfo.data.count == 0) |
5263 |
24 Jan 19 |
nicklas |
162 |
{ |
5270 |
29 Jan 19 |
nicklas |
fileCanBeImported = false; |
5263 |
24 Jan 19 |
nicklas |
Wizard.setInputStatus('lineCount', 'invalid', 'The file contains no data.'); |
5263 |
24 Jan 19 |
nicklas |
165 |
} |
5270 |
29 Jan 19 |
nicklas |
else if (importLineCount == 0) |
5263 |
24 Jan 19 |
nicklas |
167 |
{ |
5270 |
29 Jan 19 |
nicklas |
fileCanBeImported = false; |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('importLineCount', 'invalid', 'The file contains no data that can be imported.'); |
5263 |
24 Jan 19 |
nicklas |
170 |
} |
5270 |
29 Jan 19 |
nicklas |
else |
5270 |
29 Jan 19 |
nicklas |
172 |
{ |
5270 |
29 Jan 19 |
nicklas |
if (checkType == 'simplecheck') |
5270 |
29 Jan 19 |
nicklas |
174 |
{ |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('importLineCount', '', '* May change after the \'Full file check\'.'); |
5270 |
29 Jan 19 |
nicklas |
176 |
} |
5270 |
29 Jan 19 |
nicklas |
else |
5270 |
29 Jan 19 |
nicklas |
178 |
{ |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('importLineCount', 'valid'); |
5273 |
31 Jan 19 |
nicklas |
Wizard.showGoNextConfirmation(false, importLineCount + ' of ' + fileInfo.data.count + ' data lines can be imported.'); |
5270 |
29 Jan 19 |
nicklas |
181 |
} |
5270 |
29 Jan 19 |
nicklas |
182 |
} |
5263 |
24 Jan 19 |
nicklas |
183 |
|
5270 |
29 Jan 19 |
nicklas |
if (iport.setExcludedLines('tooManyColumns', fileInfo.data.TOO_MANY_COLUMNS) > 0) |
5263 |
24 Jan 19 |
nicklas |
185 |
{ |
5270 |
29 Jan 19 |
nicklas |
fileCanBeImported = false; |
5263 |
24 Jan 19 |
nicklas |
Wizard.setInputStatus('tooManyColumns', 'invalid', 'All data lines must have the same number of columns.'); |
5263 |
24 Jan 19 |
nicklas |
188 |
} |
5270 |
29 Jan 19 |
nicklas |
189 |
|
5270 |
29 Jan 19 |
nicklas |
if (iport.setExcludedLines('tooFewColumns', fileInfo.data.TOO_FEW_COLUMNS) > 0) |
5263 |
24 Jan 19 |
nicklas |
191 |
{ |
5270 |
29 Jan 19 |
nicklas |
fileCanBeImported = false; |
5263 |
24 Jan 19 |
nicklas |
Wizard.setInputStatus('tooFewColumns', 'invalid', 'All data lines must have the same number of columns.'); |
5263 |
24 Jan 19 |
nicklas |
194 |
} |
5270 |
29 Jan 19 |
nicklas |
195 |
|
5270 |
29 Jan 19 |
nicklas |
if (iport.setExcludedLines('missingPersonalNo', fileInfo.data.MISSING_PERSONAL_NO) > 0) |
5263 |
24 Jan 19 |
nicklas |
197 |
{ |
5263 |
24 Jan 19 |
nicklas |
Wizard.setInputStatus('missingPersonalNo', 'warning', 'Lines without personal number are skipped.'); |
5263 |
24 Jan 19 |
nicklas |
199 |
} |
5270 |
29 Jan 19 |
nicklas |
200 |
|
5270 |
29 Jan 19 |
nicklas |
if (iport.setExcludedLines('missingLaterality', fileInfo.data.MISSING_LATERALITY) > 0) |
5263 |
24 Jan 19 |
nicklas |
202 |
{ |
5263 |
24 Jan 19 |
nicklas |
Wizard.setInputStatus('missingLaterality', 'warning', 'Lines without laterality are skipped.'); |
5263 |
24 Jan 19 |
nicklas |
204 |
} |
5270 |
29 Jan 19 |
nicklas |
205 |
|
5270 |
29 Jan 19 |
nicklas |
if (iport.setExcludedLines('duplicateLaterality', fileInfo.data.DUPLICATE_LATERALITY) > 0) |
5263 |
24 Jan 19 |
nicklas |
207 |
{ |
5263 |
24 Jan 19 |
nicklas |
Wizard.setInputStatus('duplicateLaterality', 'warning', 'Lines with same personal number and laterality are skipped.'); |
5263 |
24 Jan 19 |
nicklas |
209 |
} |
5270 |
29 Jan 19 |
nicklas |
210 |
|
5270 |
29 Jan 19 |
nicklas |
if (iport.setExcludedLines('missingFollowUpDate', fileInfo.data.MISSING_FOLLOWUP_DATE) > 0) |
5267 |
25 Jan 19 |
nicklas |
212 |
{ |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('missingFollowUpDate', 'warning', 'Follow-up entries without a date are skipped.'); |
5267 |
25 Jan 19 |
nicklas |
214 |
} |
5270 |
29 Jan 19 |
nicklas |
215 |
|
5270 |
29 Jan 19 |
nicklas |
if (iport.setExcludedLines('duplicateFollowUp', fileInfo.data.DUPLICATE_FOLLOWUP) > 0) |
5267 |
25 Jan 19 |
nicklas |
217 |
{ |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('duplicateFollowUp', 'warning', 'Only the latest follow-up entry for the same personal number and laterality is imported.'); |
5267 |
25 Jan 19 |
nicklas |
219 |
} |
5263 |
24 Jan 19 |
nicklas |
220 |
|
5270 |
29 Jan 19 |
nicklas |
if (iport.setExcludedLines('invalidDataValue', fileInfo.data.INVALID_DATA_VALUE) > 0) |
4746 |
13 Apr 18 |
nicklas |
222 |
{ |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('invalidDataValue', 'warning', 'Lines with invalid values are skipped.'); |
4746 |
13 Apr 18 |
nicklas |
224 |
} |
4746 |
13 Apr 18 |
nicklas |
225 |
|
5275 |
31 Jan 19 |
nicklas |
if (iport.setExcludedLines('patientNotFound', checkType == 'simplecheck' ? '<i>not checked</i>' : fileInfo.data.PATIENT_NOTIN_DATABASE) > 0) |
4746 |
13 Apr 18 |
nicklas |
227 |
{ |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('patientNotFound', 'warning', 'Lines with a personal number not found in the database are skipped.'); |
4746 |
13 Apr 18 |
nicklas |
229 |
} |
4746 |
13 Apr 18 |
nicklas |
230 |
|
5270 |
29 Jan 19 |
nicklas |
if (iport.setExcludedLines('caseNotFound', checkType == 'simplecheck' ? '<i>not checked</i>' : fileInfo.data.CASE_NOTIN_DATABASE) > 0) |
3786 |
17 Mar 16 |
olle |
232 |
{ |
5270 |
29 Jan 19 |
nicklas |
Wizard.setInputStatus('caseNotFound', 'warning', 'Lines with a personal number and laterality not found in the database are skipped.'); |
3786 |
17 Mar 16 |
olle |
234 |
} |
3786 |
17 Mar 16 |
olle |
235 |
|
5270 |
29 Jan 19 |
nicklas |
Wizard.setCurrentStep(2); |
5270 |
29 Jan 19 |
nicklas |
if (fileCanBeImported) |
3786 |
17 Mar 16 |
olle |
238 |
{ |
5270 |
29 Jan 19 |
nicklas |
if (checkType == 'fullcheck') |
3786 |
17 Mar 16 |
olle |
240 |
{ |
5270 |
29 Jan 19 |
nicklas |
Doc.show('goimport'); |
5279 |
05 Feb 19 |
nicklas |
Doc.show('downloadoutputfile'); |
3786 |
17 Mar 16 |
olle |
243 |
} |
5270 |
29 Jan 19 |
nicklas |
else |
3786 |
17 Mar 16 |
olle |
245 |
{ |
5270 |
29 Jan 19 |
nicklas |
Doc.show('fullcheck'); |
3786 |
17 Mar 16 |
olle |
247 |
} |
5270 |
29 Jan 19 |
nicklas |
Doc.show('gocancel'); |
3925 |
10 May 16 |
olle |
249 |
} |
5270 |
29 Jan 19 |
nicklas |
else |
3925 |
10 May 16 |
olle |
251 |
{ |
5270 |
29 Jan 19 |
nicklas |
Wizard.setWizardStatus('messagecontainer error', 'Import is not possible.'); |
5270 |
29 Jan 19 |
nicklas |
Wizard.setNoConfirm(true); |
5270 |
29 Jan 19 |
nicklas |
Doc.show('gorestart'); |
3786 |
17 Mar 16 |
olle |
255 |
} |
5270 |
29 Jan 19 |
nicklas |
256 |
|
5273 |
31 Jan 19 |
nicklas |
Doc.show('downloadreportfile'); |
3786 |
17 Mar 16 |
olle |
258 |
} |
3786 |
17 Mar 16 |
olle |
259 |
|
5270 |
29 Jan 19 |
nicklas |
260 |
/** |
5270 |
29 Jan 19 |
nicklas |
Set the value for an 'excluded line' variable. If the |
5270 |
29 Jan 19 |
nicklas |
number of excluded lines is 0 the entire row is hidden. |
5270 |
29 Jan 19 |
nicklas |
263 |
*/ |
5270 |
29 Jan 19 |
nicklas |
iport.setExcludedLines = function(elementId, numLines) |
3786 |
17 Mar 16 |
olle |
265 |
{ |
5270 |
29 Jan 19 |
nicklas |
Doc.element(elementId).innerHTML = numLines; |
5270 |
29 Jan 19 |
nicklas |
Doc.showHide(elementId+'.row', numLines > 0); |
5270 |
29 Jan 19 |
nicklas |
return numLines; |
3786 |
17 Mar 16 |
olle |
269 |
} |
3786 |
17 Mar 16 |
olle |
270 |
|
5273 |
31 Jan 19 |
nicklas |
iport.downloadReportFile = function(event) |
3786 |
17 Mar 16 |
olle |
272 |
{ |
5273 |
31 Jan 19 |
nicklas |
var reportType = Data.get(event.currentTarget, 'report-type'); |
3786 |
17 Mar 16 |
olle |
274 |
|
3786 |
17 Mar 16 |
olle |
var url = '../Inca.servlet?ID='+App.getSessionId(); |
3951 |
18 May 16 |
olle |
url += '&cmd=DownloadIncaReportFile'; |
5273 |
31 Jan 19 |
nicklas |
url += '&reporttype='+encodeURIComponent(reportType); |
3786 |
17 Mar 16 |
olle |
window.open(url); |
3786 |
17 Mar 16 |
olle |
279 |
} |
3786 |
17 Mar 16 |
olle |
280 |
|
3786 |
17 Mar 16 |
olle |
iport.submit = function() |
3786 |
17 Mar 16 |
olle |
282 |
{ |
5273 |
31 Jan 19 |
nicklas |
Doc.hide('downloadreportfile'); |
5275 |
31 Jan 19 |
nicklas |
Doc.hide('downloadoutputfile'); |
5273 |
31 Jan 19 |
nicklas |
285 |
|
3786 |
17 Mar 16 |
olle |
var frm = document.forms['reggie']; |
3786 |
17 Mar 16 |
olle |
var exportDate = frm.exportDate.value; |
3786 |
17 Mar 16 |
olle |
288 |
|
3786 |
17 Mar 16 |
olle |
var formData = new FormData(); |
3786 |
17 Mar 16 |
olle |
var files = frm.importfile.files; |
3786 |
17 Mar 16 |
olle |
for (var i = 0; i < files.length; i++) |
3786 |
17 Mar 16 |
olle |
292 |
{ |
3786 |
17 Mar 16 |
olle |
var file = files[i]; |
3786 |
17 Mar 16 |
olle |
formData.append('incafiles[]', file, file.name); |
3786 |
17 Mar 16 |
olle |
295 |
} |
3786 |
17 Mar 16 |
olle |
296 |
|
3786 |
17 Mar 16 |
olle |
var url = '../Inca.servlet?ID='+App.getSessionId(); |
3786 |
17 Mar 16 |
olle |
url += '&cmd=ImportInca'; |
3786 |
17 Mar 16 |
olle |
url += '&exportdate='+encodeURIComponent(exportDate); |
3786 |
17 Mar 16 |
olle |
300 |
|
3786 |
17 Mar 16 |
olle |
// POST |
3920 |
03 May 16 |
olle |
Wizard.showLoadingAnimation('Importing INCA data...', 'inca-import-progress'); |
3786 |
17 Mar 16 |
olle |
Wizard.asyncJsonRequest(url, iport.submissionResults, 'POST', formData); |
3786 |
17 Mar 16 |
olle |
304 |
} |
3786 |
17 Mar 16 |
olle |
305 |
|
3786 |
17 Mar 16 |
olle |
iport.submissionResults = function(response) |
3786 |
17 Mar 16 |
olle |
307 |
{ |
5275 |
31 Jan 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5273 |
31 Jan 19 |
nicklas |
Doc.show('downloadreportfile'); |
5275 |
31 Jan 19 |
nicklas |
Doc.show('downloadoutputfile'); |
3786 |
17 Mar 16 |
olle |
Doc.show('gorestart'); |
3786 |
17 Mar 16 |
olle |
312 |
} |
3786 |
17 Mar 16 |
olle |
313 |
|
3786 |
17 Mar 16 |
olle |
return iport; |
3786 |
17 Mar 16 |
olle |
315 |
}(); |
3786 |
17 Mar 16 |
olle |
316 |
|
3786 |
17 Mar 16 |
olle |
Doc.onLoad(Iport.initPage); |
3786 |
17 Mar 16 |
olle |
318 |
|