4173 |
24 Oct 16 |
nicklas |
var Delivery = function() |
4173 |
24 Oct 16 |
nicklas |
2 |
{ |
4173 |
24 Oct 16 |
nicklas |
var delivery = {}; |
4173 |
24 Oct 16 |
nicklas |
var debug = 0; |
4173 |
24 Oct 16 |
nicklas |
5 |
|
4173 |
24 Oct 16 |
nicklas |
// Page initialization |
4173 |
24 Oct 16 |
nicklas |
delivery.initPage = function() |
4173 |
24 Oct 16 |
nicklas |
8 |
{ |
4173 |
24 Oct 16 |
nicklas |
// Step 1 |
4173 |
24 Oct 16 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', delivery.validateStep1); |
4173 |
24 Oct 16 |
nicklas |
Events.addEventHandler('workList', 'change', delivery.worklistOnChange); |
4173 |
24 Oct 16 |
nicklas |
Events.addEventHandler('deliveredDate', 'change', Wizard.validateDate); |
4173 |
24 Oct 16 |
nicklas |
13 |
|
4173 |
24 Oct 16 |
nicklas |
// Navigation |
4173 |
24 Oct 16 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
4173 |
24 Oct 16 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
4173 |
24 Oct 16 |
nicklas |
Buttons.addClickHandler('godownload', delivery.downloadDelivery); |
4173 |
24 Oct 16 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
4173 |
24 Oct 16 |
nicklas |
19 |
|
4173 |
24 Oct 16 |
nicklas |
// Final registration |
4173 |
24 Oct 16 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', delivery.submit); |
4173 |
24 Oct 16 |
nicklas |
22 |
|
4173 |
24 Oct 16 |
nicklas |
var url = '../Outtake.servlet?ID='+App.getSessionId(); |
4173 |
24 Oct 16 |
nicklas |
url += '&cmd=GetOuttakeWorklists&forDelivery=1'; |
4173 |
24 Oct 16 |
nicklas |
Wizard.showLoadingAnimation('Loading outtake work lists...'); |
4173 |
24 Oct 16 |
nicklas |
Wizard.asyncJsonRequest(url, delivery.initializeStep1); |
4173 |
24 Oct 16 |
nicklas |
27 |
} |
4173 |
24 Oct 16 |
nicklas |
28 |
|
4173 |
24 Oct 16 |
nicklas |
delivery.initializeStep1 = function(response) |
4173 |
24 Oct 16 |
nicklas |
30 |
{ |
4173 |
24 Oct 16 |
nicklas |
var frm = document.forms['reggie']; |
4173 |
24 Oct 16 |
nicklas |
var workLists = response.workLists; |
4173 |
24 Oct 16 |
nicklas |
33 |
|
4173 |
24 Oct 16 |
nicklas |
var workList = frm.workList; |
4173 |
24 Oct 16 |
nicklas |
if (workLists.length > 0) |
4173 |
24 Oct 16 |
nicklas |
36 |
{ |
4173 |
24 Oct 16 |
nicklas |
for (var i=0; i < workLists.length; i++) |
4173 |
24 Oct 16 |
nicklas |
38 |
{ |
4173 |
24 Oct 16 |
nicklas |
var list = workLists[i]; |
6326 |
14 Jun 21 |
nicklas |
var name = list.name + ' (' + list.size+(list.parentType?' '+list.parentType : '') + ')'; |
4173 |
24 Oct 16 |
nicklas |
var option = new Option(name, list.id); |
4173 |
24 Oct 16 |
nicklas |
option.workList = list; |
4173 |
24 Oct 16 |
nicklas |
workList.options[workList.length] = option; |
4173 |
24 Oct 16 |
nicklas |
44 |
} |
4173 |
24 Oct 16 |
nicklas |
Events.sendChangeEvent(workList); |
4173 |
24 Oct 16 |
nicklas |
46 |
} |
4173 |
24 Oct 16 |
nicklas |
else |
4173 |
24 Oct 16 |
nicklas |
48 |
{ |
4173 |
24 Oct 16 |
nicklas |
Wizard.setFatalError('No outtake works lists available for processing.'); |
4173 |
24 Oct 16 |
nicklas |
return; |
4173 |
24 Oct 16 |
nicklas |
51 |
} |
4173 |
24 Oct 16 |
nicklas |
52 |
|
4173 |
24 Oct 16 |
nicklas |
Doc.show('step-1'); |
4173 |
24 Oct 16 |
nicklas |
Doc.show('godownload'); |
4173 |
24 Oct 16 |
nicklas |
Doc.show('goregister'); |
4173 |
24 Oct 16 |
nicklas |
56 |
} |
4173 |
24 Oct 16 |
nicklas |
57 |
|
4173 |
24 Oct 16 |
nicklas |
delivery.worklistOnChange = function() |
4173 |
24 Oct 16 |
nicklas |
59 |
{ |
4173 |
24 Oct 16 |
nicklas |
var frm = document.forms['reggie']; |
4173 |
24 Oct 16 |
nicklas |
var workList = frm.workList[frm.workList.selectedIndex].workList; |
4173 |
24 Oct 16 |
nicklas |
frm.comments.value = workList.comments; |
4173 |
24 Oct 16 |
nicklas |
63 |
} |
4173 |
24 Oct 16 |
nicklas |
64 |
|
4173 |
24 Oct 16 |
nicklas |
65 |
|
4173 |
24 Oct 16 |
nicklas |
delivery.validateStep1 = function(event) |
4173 |
24 Oct 16 |
nicklas |
67 |
{ |
4173 |
24 Oct 16 |
nicklas |
var frm = document.forms['reggie']; |
4173 |
24 Oct 16 |
nicklas |
69 |
|
4173 |
24 Oct 16 |
nicklas |
var valid = true; |
4173 |
24 Oct 16 |
nicklas |
valid &= frm.workList.selectedIndex >= 0; |
4173 |
24 Oct 16 |
nicklas |
valid &= Wizard.isValid('deliveredDate'); |
4173 |
24 Oct 16 |
nicklas |
73 |
|
4173 |
24 Oct 16 |
nicklas |
if (!valid) event.preventDefault(); |
4173 |
24 Oct 16 |
nicklas |
75 |
} |
4173 |
24 Oct 16 |
nicklas |
76 |
|
6824 |
30 Aug 22 |
nicklas |
delivery.downloadDelivery = function() |
4173 |
24 Oct 16 |
nicklas |
78 |
{ |
4173 |
24 Oct 16 |
nicklas |
var frm = document.forms['reggie']; |
4173 |
24 Oct 16 |
nicklas |
80 |
|
4173 |
24 Oct 16 |
nicklas |
var url = '../Outtake.servlet?ID='+App.getSessionId(); |
4173 |
24 Oct 16 |
nicklas |
url += '&cmd=DownloadDeliveryFile'; |
4173 |
24 Oct 16 |
nicklas |
url += '&workListId='+frm.workList.value; |
4173 |
24 Oct 16 |
nicklas |
if (frm.useExternalId.checked) |
4173 |
24 Oct 16 |
nicklas |
85 |
{ |
4173 |
24 Oct 16 |
nicklas |
url += '&useExternalId=1'; |
4173 |
24 Oct 16 |
nicklas |
87 |
} |
4173 |
24 Oct 16 |
nicklas |
location.href = url; |
4173 |
24 Oct 16 |
nicklas |
89 |
} |
4173 |
24 Oct 16 |
nicklas |
90 |
|
4173 |
24 Oct 16 |
nicklas |
delivery.submit = function() |
4173 |
24 Oct 16 |
nicklas |
92 |
{ |
4173 |
24 Oct 16 |
nicklas |
var frm = document.forms['reggie']; |
4173 |
24 Oct 16 |
nicklas |
94 |
|
4173 |
24 Oct 16 |
nicklas |
var submitInfo = {}; |
4173 |
24 Oct 16 |
nicklas |
submitInfo.workList = parseInt(frm.workList.value, 10); |
4173 |
24 Oct 16 |
nicklas |
97 |
|
4173 |
24 Oct 16 |
nicklas |
// var failed = Doc.element('outcomeFailed').checked; |
4173 |
24 Oct 16 |
nicklas |
// submitInfo.failed = failed; |
4173 |
24 Oct 16 |
nicklas |
100 |
|
4173 |
24 Oct 16 |
nicklas |
submitInfo.deliveredDate = frm.deliveredDate.value; |
4173 |
24 Oct 16 |
nicklas |
submitInfo.comments = frm.comments.value; |
4173 |
24 Oct 16 |
nicklas |
103 |
|
4173 |
24 Oct 16 |
nicklas |
var url = '../Outtake.servlet?ID='+App.getSessionId(); |
4173 |
24 Oct 16 |
nicklas |
url += '&cmd=RegisterOuttakeDelivered'; |
4173 |
24 Oct 16 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
4173 |
24 Oct 16 |
nicklas |
Wizard.asyncJsonRequest(url, delivery.submissionResults, 'POST', JSON.stringify(submitInfo)); |
4173 |
24 Oct 16 |
nicklas |
108 |
|
4173 |
24 Oct 16 |
nicklas |
109 |
} |
4173 |
24 Oct 16 |
nicklas |
110 |
|
4173 |
24 Oct 16 |
nicklas |
delivery.submissionResults = function(response) |
4173 |
24 Oct 16 |
nicklas |
112 |
{ |
4173 |
24 Oct 16 |
nicklas |
Wizard.showFinalMessage(response.messages); |
4173 |
24 Oct 16 |
nicklas |
Doc.show('gorestart'); |
4173 |
24 Oct 16 |
nicklas |
115 |
} |
4173 |
24 Oct 16 |
nicklas |
116 |
|
4173 |
24 Oct 16 |
nicklas |
return delivery; |
4173 |
24 Oct 16 |
nicklas |
118 |
}(); |
4173 |
24 Oct 16 |
nicklas |
119 |
|
4173 |
24 Oct 16 |
nicklas |
Doc.onLoad(Delivery.initPage); |
4173 |
24 Oct 16 |
nicklas |
121 |
|