Blame view
app/partials/enterFuelOrder/enterFuelOrder.controller.js
5.35 KB
8f7dbe97c
![]() |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
'use strict'; angular.module('acufuel') .controller('enterFuelOrderController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'enterFuelOrderService', enterFuelOrderController]); function enterFuelOrderController($scope, $rootScope, $uibModal, $filter, $http, enterFuelOrderService) { $scope.showLoader = true; $scope.companyList = {}; enterFuelOrderService.getAllCompanies().then(function(result) { $scope.showLoader = false; $scope.companyList = result; |
961a97a2f
|
15 |
//console.log("---",result); |
8f7dbe97c
![]() |
16 17 18 |
}) $scope.order = {}; |
a55ef20b5
![]() |
19 |
$scope.dispatchOrder = {}; |
e95d89b77
![]() |
20 |
$scope.dispatchOrder.fuelOrderList = []; |
8f7dbe97c
![]() |
21 |
$scope.order.upliftDate = ''; |
961a97a2f
|
22 |
//$scope.order.departingDate = ''; |
8f7dbe97c
![]() |
23 24 25 |
$scope.selectedCompanyName = ''; $scope.selectedCompanyId = ''; $scope.marginId = ''; |
e563b15f3
|
26 |
$scope.selectedTier = ''; |
8f7dbe97c
![]() |
27 |
|
8f7dbe97c
![]() |
28 29 |
$scope.getAircraft = function(company){ $scope.selectedCompanyName = company; |
961a97a2f
|
30 |
|
8f7dbe97c
![]() |
31 |
$scope.showLoader = true; |
961a97a2f
|
32 |
//console.log(--company---,$scope.selectedCompanyName); |
8f7dbe97c
![]() |
33 34 |
for (var i = 0; i < $scope.companyList.length; i++) { if ($scope.companyList[i].companyName == company) { |
961a97a2f
|
35 36 |
//console.log($scope.companyList[i].margin); //console.log($scope.companyList[i].marginAVGAS); |
efcd5bfce
|
37 38 39 40 41 |
if($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null){ enterFuelOrderService.getFuelCost($scope.companyList[i].id).then(function(margins) { $scope.marginList = margins; //console.log('$scope.marginList', $scope.marginList); }) |
a9aef0b1c
|
42 |
} else if ($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS == null) { |
961a97a2f
|
43 44 |
//console.log('--------------------',$scope.companyList[i].margin); //console.log('--------------------',$scope.companyList[i].marginAVGAS); |
efcd5bfce
|
45 46 47 |
enterFuelOrderService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) { $scope.marginList = margins; }) |
a9aef0b1c
|
48 |
} else if ($scope.companyList[i].margin == null && $scope.companyList[i].marginAVGAS != null) { |
efcd5bfce
|
49 50 51 |
enterFuelOrderService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) { $scope.marginList = margins; }) |
a9aef0b1c
|
52 53 54 55 |
} else if ($scope.companyList[i].margin == null && $scope.companyList[i].marginAVGAS == null) { enterFuelOrderService.getPapFuelPricing($scope.companyList[i].id).then(function(margins) { $scope.marginList = margins; }) |
961a97a2f
|
56 |
//console.log('--------------------',$scope.companyList[i].margin); |
efcd5bfce
|
57 |
} |
8f7dbe97c
![]() |
58 |
$scope.selectedCompanyId = $scope.companyList[i].id; |
a9aef0b1c
|
59 |
|
8f7dbe97c
![]() |
60 61 62 |
if ($scope.selectedCompanyId != '') { enterFuelOrderService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { $scope.aircraftList = aircraft; |
961a97a2f
|
63 |
//console.log("aircraft",$scope.aircraftList); |
8f7dbe97c
![]() |
64 65 |
}) } |
a9aef0b1c
|
66 67 68 69 70 |
if($scope.companyList[i].margin == null) { $scope.tierList = []; $scope.tierList.push({ 'minTierBreak': '0', 'maxTierBreak': '∞' }); |
8f7dbe97c
![]() |
71 |
$scope.showLoader = false; |
a9aef0b1c
|
72 73 74 75 76 77 |
} else { $scope.marginId = $scope.companyList[i].margin.id; if ($scope.marginId != '') { enterFuelOrderService.getJetTiers($scope.marginId).then(function(tiers) { $scope.tierList = tiers; $scope.showLoader = false; |
e563b15f3
|
78 79 |
$scope.selectedTier = $scope.tierList[0]; //console.log("--tier--",$scope.tierList) |
a9aef0b1c
|
80 81 82 83 |
}) }else{ $scope.showLoader = false; } |
8f7dbe97c
![]() |
84 85 86 87 88 |
} } } } |
e563b15f3
|
89 90 91 92 |
$scope.tiervalue=function(){ $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; //console.log('tier value', $scope.order.tierBreak); } |
efcd5bfce
|
93 |
$scope.setCost = function(cost){ |
efcd5bfce
|
94 95 96 97 |
if(cost != null) { var obj =JSON.parse(cost); $scope.order.fboCost = obj.cost; } |
25082c4e3
|
98 99 100 101 |
} $scope.cancelOrder = function() { $scope.order = {}; |
efcd5bfce
|
102 103 |
} |
8f7dbe97c
![]() |
104 |
$scope.dispatchFuel = function(){ |
e95d89b77
![]() |
105 |
$scope.showLoader = true; |
8f7dbe97c
![]() |
106 107 |
$scope.order.companyId = $scope.selectedCompanyId; if ($scope.order.upliftDate != '') { |
b90971c06
|
108 109 110 111 112 |
var currentDate = new Date(); var hours = currentDate.getHours(); var min = currentDate.getMinutes(); var sec = currentDate.getSeconds(); $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; |
8f7dbe97c
![]() |
113 114 |
$scope.order.upliftDate = new Date($scope.order.upliftDate); $scope.order.upliftDate = $scope.order.upliftDate.getTime(); |
b90971c06
|
115 |
//console.log("---date---",$scope.order.upliftDate) |
8f7dbe97c
![]() |
116 |
} |
961a97a2f
|
117 |
/*if ($scope.order.departingDate != '') { |
8f7dbe97c
![]() |
118 119 |
$scope.order.departingDate = new Date($scope.order.departingDate); $scope.order.departingDate = $scope.order.departingDate.getTime(); |
961a97a2f
|
120 |
}*/ |
ae523d5ef
|
121 |
|
a9aef0b1c
|
122 |
$scope.order.status = 'pending'; |
ae523d5ef
|
123 |
|
961a97a2f
|
124 |
//console.log($scope.order.quotePrice); |
efcd5bfce
|
125 |
var obj =JSON.parse($scope.order.priceQuote); |
961a97a2f
|
126 |
//console.log('obj.papMargin',obj.papMargin); |
efcd5bfce
|
127 |
$scope.order.priceQuote = obj.papMargin; |
961a97a2f
|
128 129 130 131 |
var aircraftObj =JSON.parse($scope.order.aircraftName); $scope.order.aircraftName = aircraftObj.tail; $scope.order.make = aircraftObj.make; $scope.order.model = aircraftObj.model; |
e95d89b77
![]() |
132 |
$scope.dispatchOrder.fuelOrderList.push($scope.order); |
961a97a2f
|
133 |
//console.log('$scope.order', $scope.dispatchOrder); |
a55ef20b5
![]() |
134 |
enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { |
b90971c06
|
135 |
//console.log("--final data--",$scope.dispatchOrder) |
961a97a2f
|
136 |
//console.log('result', result); |
e95d89b77
![]() |
137 138 139 140 141 |
$scope.showLoader = false; $scope.order = {}; toastr.success('Fuel Order Dispatched Successfully', { closeButton: true }) |
8f7dbe97c
![]() |
142 143 144 145 |
}) } } |