Blame view

app/partials/enterFuelOrder/enterFuelOrder.controller.js 8.34 KB
8f7dbe97c   Swarn Singh   fuel order comple...
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;
0173d74ad   Kuldeep Arora   source autopopula...
15
  		//console.log("===company====",result)
8f7dbe97c   Swarn Singh   fuel order comple...
16
17
18
  	})
  
  	$scope.order = {};
a55ef20b5   Swarn Singh   schedular added
19
  	$scope.dispatchOrder = {};
e95d89b77   Swarn Singh   integrate editor ...
20
  	$scope.dispatchOrder.fuelOrderList = [];
8f7dbe97c   Swarn Singh   fuel order comple...
21
  	$scope.order.upliftDate = '';
961a97a2f   Kuldeep Arora   Enhancement in de...
22
  	//$scope.order.departingDate = '';
8f7dbe97c   Swarn Singh   fuel order comple...
23
24
25
  	$scope.selectedCompanyName = '';
  	$scope.selectedCompanyId = '';
  	$scope.marginId = '';
e563b15f3   Kuldeep Arora   updates
26
  	$scope.selectedTier = '';
8f7dbe97c   Swarn Singh   fuel order comple...
27

8f7dbe97c   Swarn Singh   fuel order comple...
28
29
  	$scope.getAircraft = function(company){
  		$scope.selectedCompanyName = company;
0173d74ad   Kuldeep Arora   source autopopula...
30

961a97a2f   Kuldeep Arora   Enhancement in de...
31
  		
8f7dbe97c   Swarn Singh   fuel order comple...
32
33
34
  		$scope.showLoader = true;
  		for (var i = 0; i < $scope.companyList.length; i++) {
  			if ($scope.companyList[i].companyName == company) {
0173d74ad   Kuldeep Arora   source autopopula...
35
36
37
38
  					$scope.order.certificateType = $scope.companyList[i].certificateType;
  					$scope.baseTenant = $scope.companyList[i].baseTenant;
  					$scope.contractFuelVendor = $scope.companyList[i].contractFuelVendor;
  					$scope.fuelerlinxCustomer = $scope.companyList[i].fuelerlinxCustomer;
efcd5bfce   Anchit Jindal   minor changes
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;
efcd5bfce   Anchit Jindal   minor changes
42
  					})
a9aef0b1c   Anchit Jindal   new changes imple...
43
  				} else if ($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS == null) {
efcd5bfce   Anchit Jindal   minor changes
44
45
  					enterFuelOrderService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) {
  						$scope.marginList = margins;
00d325f95   Kuldeep Arora   logs
46
47
  					}) 
  				}	else if ($scope.companyList[i].margin == null && $scope.companyList[i].marginAVGAS != null) {
efcd5bfce   Anchit Jindal   minor changes
48
49
50
  					enterFuelOrderService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) {
  			        	$scope.marginList = margins;
  			        })
a9aef0b1c   Anchit Jindal   new changes imple...
51
52
53
54
  				} 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   Anchit Jindal   minor changes
55
  				}
8f7dbe97c   Swarn Singh   fuel order comple...
56
  				$scope.selectedCompanyId = $scope.companyList[i].id;
a9aef0b1c   Anchit Jindal   new changes imple...
57
  				
8f7dbe97c   Swarn Singh   fuel order comple...
58
59
60
61
62
  				if ($scope.selectedCompanyId != '') {
  					enterFuelOrderService.getAircraft($scope.selectedCompanyId).then(function(aircraft) {
  						$scope.aircraftList = aircraft;
  					})
  				}
a9aef0b1c   Anchit Jindal   new changes imple...
63
64
65
66
67
  				if($scope.companyList[i].margin == null) {
  					$scope.tierList = [];
  					$scope.tierList.push({
  	        		  	'minTierBreak': '0', 'maxTierBreak': '∞'
  					});
8f7dbe97c   Swarn Singh   fuel order comple...
68
  					$scope.showLoader = false;
a9aef0b1c   Anchit Jindal   new changes imple...
69
70
71
72
73
74
  				} 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   Kuldeep Arora   updates
75
  			                $scope.selectedTier = $scope.tierList[0];
a9aef0b1c   Anchit Jindal   new changes imple...
76
77
78
79
  			            })
  					}else{
  						$scope.showLoader = false;
  					}
8f7dbe97c   Swarn Singh   fuel order comple...
80
81
82
83
84
  				}
  			}
  		}
  
  	}
e563b15f3   Kuldeep Arora   updates
85
86
  	$scope.tiervalue=function(){
  		$scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak;
e563b15f3   Kuldeep Arora   updates
87
  	}
2075411ed   Kuldeep Arora   create fuel order...
88
89
90
91
92
93
94
  
  
  	$scope.cancelOrder = function() {
  		$scope.order = {};
  	}
  	
  	
efcd5bfce   Anchit Jindal   minor changes
95
  	$scope.setCost = function(cost){
efcd5bfce   Anchit Jindal   minor changes
96
97
98
99
  		if(cost != null) {
  			var obj =JSON.parse(cost);
  			$scope.order.fboCost = obj.cost;
  		}
25082c4e3   Anchit Jindal   flight dept order...
100
  	}
39a850f31   Kuldeep Arora   total calculation
101
      
d1e8d9afb   Kuldeep Arora   fuel order & home...
102
103
104
      $scope.addTotal = function(value, valueOf) {
  		if (value != undefined && valueOf != undefined) {
  			value = JSON.parse(value)
39a850f31   Kuldeep Arora   total calculation
105
  			$scope.order.total = Math.abs(value.papTotal) * valueOf; 
d1e8d9afb   Kuldeep Arora   fuel order & home...
106
107
  		}
  	}
2075411ed   Kuldeep Arora   create fuel order...
108

8f7dbe97c   Swarn Singh   fuel order comple...
109
  	$scope.dispatchFuel = function(){
e95d89b77   Swarn Singh   integrate editor ...
110
  		$scope.showLoader = true;
0173d74ad   Kuldeep Arora   source autopopula...
111
  		
8f7dbe97c   Swarn Singh   fuel order comple...
112
  		$scope.order.companyId = $scope.selectedCompanyId;
2075411ed   Kuldeep Arora   create fuel order...
113
  		$scope.order.companyName = $scope.order.companyName; 
961a97a2f   Kuldeep Arora   Enhancement in de...
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;
20f645d6f   Kuldeep Arora   fuelorder
118
  		//$scope.order.fuelOn = $scope.order.fuelOn;
2075411ed   Kuldeep Arora   create fuel order...
119
120
121
  
  		$scope.order.invoiced = $scope.order.invoiced;
  		$scope.order.volume = $scope.order.volume; 
0173d74ad   Kuldeep Arora   source autopopula...
122
         // $scope.order.source = $scope.order.source; 
084c4873b   Kuldeep Arora   validation for re...
123
          
2075411ed   Kuldeep Arora   create fuel order...
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
          $scope.order.total = $scope.order.total;
  
          var obj =JSON.parse($scope.order.priceQuote);
  		$scope.order.priceQuote = obj.papTotal;
  		$scope.order.fboCost = obj.cost;
  		$scope.order.productName = obj.productName;
  
  		$scope.order.etaTime = $scope.order.etaTime;
          $scope.order.etdTime = $scope.order.etdTime;
          $scope.order.certificateType = $scope.order.certificateType;
  		var currentDate = new Date();
          var hours = currentDate.getHours();
          var min = currentDate.getMinutes();
          var sec = currentDate.getSeconds();
          if ($scope.order.upliftDate != '') {
                  $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec;
      			$scope.order.upliftDate = new Date($scope.order.upliftDate);
      			$scope.order.upliftDate = $scope.order.upliftDate.getTime();
      		}
  
  		 
  		if ($scope.order.departingDate != '') {
  			$scope.order.departingDate = $scope.order.departingDate + ' ' + hours + ':' + min + ':' + sec;
  			$scope.order.departingDate = new Date($scope.order.departingDate);
  			$scope.order.departingDate = $scope.order.departingDate.getTime();
  		}
084c4873b   Kuldeep Arora   validation for re...
150
151
152
153
154
155
156
157
158
  
  		if($scope.order.status === null || $scope.order.status === undefined){
  
  			$scope.order.status = "pending"; //default status
  
  		}else {
  			
  			$scope.order.status = $scope.order.status;
  		}
20f645d6f   Kuldeep Arora   fuelorder
159
160
161
162
163
  		if($scope.order.fuelOn === null || $scope.order.fuelOn ===undefined){
  			$scope.order.fuelOn = "Arrival"; //default fuelon
  		}else {
  			$scope.order.fuelOn = $scope.order.fuelOn ;
  		}
0173d74ad   Kuldeep Arora   source autopopula...
164
165
  
  		if($scope.baseTenant && $scope.contractFuelVendor ){
6c795a9f9   Kuldeep Arora   tenant/caa status...
166
  			$scope.order.source = "Tenant/CAA" ;
0173d74ad   Kuldeep Arora   source autopopula...
167
168
169
170
171
172
  		}else if($scope.baseTenant)
  		{
  			$scope.order.source = "Tenant/Base Customer";
  		}else if($scope.contractFuelVendor){
  			$scope.order.source = "CAA Member";
  		}
e95d89b77   Swarn Singh   integrate editor ...
173
  		$scope.dispatchOrder.fuelOrderList.push($scope.order);
2075411ed   Kuldeep Arora   create fuel order...
174
  		
a55ef20b5   Swarn Singh   schedular added
175
  		enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
e95d89b77   Swarn Singh   integrate editor ...
176
177
  			$scope.showLoader = false;
  			$scope.order = {};
bb8754ed9   Kuldeep Arora   pagination fuel t...
178
179
180
181
  			$scope.dispatchOrder={};
  			$scope.order.source='';
  			$scope.baseTenant=false;
  			$scope.contractFuelVendor=false;
2075411ed   Kuldeep Arora   create fuel order...
182
  			toastr.success('Fuel Order Created Successfully', {
e95d89b77   Swarn Singh   integrate editor ...
183
184
                closeButton: true
              })
8f7dbe97c   Swarn Singh   fuel order comple...
185
186
  		})
  	}
2075411ed   Kuldeep Arora   create fuel order...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
  
  	$scope.etaTimeList=[];
      $scope.etdTimeList =[];
  
  	$scope.etaTimeList  = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"},
                        {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"},
                        {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"},
                        {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"},
                        {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"},
                        {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},];
  
      $scope.etdTimeList  = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"},
                        {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"},
                        {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"},
                        {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"},
                        {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"},
                        {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},];
8f7dbe97c   Swarn Singh   fuel order comple...
204
  }