Blame view
app/partials/enterFuelOrder/enterFuelOrder.controller.js
4.7 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 = ''; |
8f7dbe97c
![]() |
26 27 |
$scope.getAircraft = function(company){ $scope.selectedCompanyName = company; |
961a97a2f
|
28 |
|
8f7dbe97c
![]() |
29 |
$scope.showLoader = true; |
961a97a2f
|
30 |
//console.log(--company---,$scope.selectedCompanyName); |
8f7dbe97c
![]() |
31 32 |
for (var i = 0; i < $scope.companyList.length; i++) { if ($scope.companyList[i].companyName == company) { |
961a97a2f
|
33 34 |
//console.log($scope.companyList[i].margin); //console.log($scope.companyList[i].marginAVGAS); |
efcd5bfce
|
35 36 37 38 39 |
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
|
40 |
} else if ($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS == null) { |
961a97a2f
|
41 42 |
//console.log('--------------------',$scope.companyList[i].margin); //console.log('--------------------',$scope.companyList[i].marginAVGAS); |
efcd5bfce
|
43 44 45 |
enterFuelOrderService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) { $scope.marginList = margins; }) |
a9aef0b1c
|
46 |
} else if ($scope.companyList[i].margin == null && $scope.companyList[i].marginAVGAS != null) { |
efcd5bfce
|
47 48 49 |
enterFuelOrderService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) { $scope.marginList = margins; }) |
a9aef0b1c
|
50 51 52 53 |
} 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
|
54 |
//console.log('--------------------',$scope.companyList[i].margin); |
efcd5bfce
|
55 |
} |
8f7dbe97c
![]() |
56 |
$scope.selectedCompanyId = $scope.companyList[i].id; |
a9aef0b1c
|
57 |
|
8f7dbe97c
![]() |
58 59 60 |
if ($scope.selectedCompanyId != '') { enterFuelOrderService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { $scope.aircraftList = aircraft; |
961a97a2f
|
61 |
//console.log("aircraft",$scope.aircraftList); |
8f7dbe97c
![]() |
62 63 |
}) } |
a9aef0b1c
|
64 65 66 67 68 |
if($scope.companyList[i].margin == null) { $scope.tierList = []; $scope.tierList.push({ 'minTierBreak': '0', 'maxTierBreak': '∞' }); |
8f7dbe97c
![]() |
69 |
$scope.showLoader = false; |
a9aef0b1c
|
70 71 72 73 74 75 76 77 78 79 |
} else { $scope.marginId = $scope.companyList[i].margin.id; if ($scope.marginId != '') { enterFuelOrderService.getJetTiers($scope.marginId).then(function(tiers) { $scope.tierList = tiers; $scope.showLoader = false; }) }else{ $scope.showLoader = false; } |
8f7dbe97c
![]() |
80 81 82 83 84 |
} } } } |
efcd5bfce
|
85 |
$scope.setCost = function(cost){ |
efcd5bfce
|
86 87 88 89 |
if(cost != null) { var obj =JSON.parse(cost); $scope.order.fboCost = obj.cost; } |
25082c4e3
|
90 91 92 93 |
} $scope.cancelOrder = function() { $scope.order = {}; |
efcd5bfce
|
94 95 |
} |
8f7dbe97c
![]() |
96 |
$scope.dispatchFuel = function(){ |
e95d89b77
![]() |
97 |
$scope.showLoader = true; |
8f7dbe97c
![]() |
98 99 100 101 102 |
$scope.order.companyId = $scope.selectedCompanyId; if ($scope.order.upliftDate != '') { $scope.order.upliftDate = new Date($scope.order.upliftDate); $scope.order.upliftDate = $scope.order.upliftDate.getTime(); } |
961a97a2f
|
103 |
/*if ($scope.order.departingDate != '') { |
8f7dbe97c
![]() |
104 105 |
$scope.order.departingDate = new Date($scope.order.departingDate); $scope.order.departingDate = $scope.order.departingDate.getTime(); |
961a97a2f
|
106 |
}*/ |
ae523d5ef
|
107 |
|
a9aef0b1c
|
108 |
$scope.order.status = 'pending'; |
ae523d5ef
|
109 |
|
961a97a2f
|
110 |
//console.log($scope.order.quotePrice); |
efcd5bfce
|
111 |
var obj =JSON.parse($scope.order.priceQuote); |
961a97a2f
|
112 |
//console.log('obj.papMargin',obj.papMargin); |
efcd5bfce
|
113 |
$scope.order.priceQuote = obj.papMargin; |
961a97a2f
|
114 115 116 117 |
var aircraftObj =JSON.parse($scope.order.aircraftName); $scope.order.aircraftName = aircraftObj.tail; $scope.order.make = aircraftObj.make; $scope.order.model = aircraftObj.model; |
e95d89b77
![]() |
118 |
$scope.dispatchOrder.fuelOrderList.push($scope.order); |
961a97a2f
|
119 |
//console.log('$scope.order', $scope.dispatchOrder); |
a55ef20b5
![]() |
120 |
enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { |
961a97a2f
|
121 122 |
//console.log("--final data--",$scope.dispatchOrder) //console.log('result', 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 |
}) } } |