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