-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapprovalInputCtrl.js
More file actions
54 lines (51 loc) · 1.4 KB
/
Copy pathapprovalInputCtrl.js
File metadata and controls
54 lines (51 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
four51.app.controller('ApprovalInputCtrl', ['$scope', '$location', '$rootScope', 'Order', 'Address', function ($scope, $location, $rootScope, Order, Address) {
$scope.approveOrder = function() {
$scope.loadingIndicator = true;
$scope.approveClicked = true;
Order.approve($scope.order,
function(data) {
$scope.order = data;
if ($scope.order.IsMultipleShip()) {
angular.forEach(data.LineItems, function(item) {
if (item.ShipAddressID) {
Address.get(item.ShipAddressID, function(add) {
item.ShipAddress = add;
});
}
});
}
else {
Address.get(data.ShipAddressID || data.LineItems[0].ShipAddressID, function(add) {
data.ShipAddress = add;
});
}
Address.get(data.BillAddressID, function(add){
data.BillAddress = add;
});
$scope.loadingIndicator = false;
},
function(ex) {
$scope.approveClicked = false;
$scope.loadingIndicator = false;
$scope.error = ex.Detail;
}
);
}
$scope.declineOrder = function() {
$scope.loadingIndicator = true;
Order.decline($scope.order,
function(data) {
$scope.order = data;
$scope.loadingIndicator = false;
},
function(ex) {
$scope.loadingIndicator = false;
$scope.error = "An error occurred while processing.";
}
);
}
$scope.editOrder = function() {
$scope.loadingIndicator = true;
$location.path('cart/' + $scope.order.ID);
}
}]);