Blame view

app/partials/customers/customers.controller.js 22.4 KB
feacde5ff   Rishav   setup acuefuel in...
1
  'use strict';
9d840540f   Anchit Jindal   fixed bugs and ne...
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
  //Load controller
  angular.module('acufuel')
  	.controller('customersController', [ '$scope', '$rootScope', '$uibModal', '$filter', '$http', '$state', 'CustomersService', 'ViewCompanyService', 'NgTableParams', 'fuelOrdersService', 'enterFuelOrderService', customersController ]);
  
  function customersController($scope, $rootScope, $uibModal, $filter, $http, $state, CustomersService, ViewCompanyService, NgTableParams, fuelOrdersService, enterFuelOrderService) {
  	$(document).ready(function() {
  		// $('#example').DataTable();
  	});
  	$scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId'))
  	$scope.reset2 = function() {
  		$("input").val("");
  		$scope.removeMarginValidation();
  	}
  
  	$scope.order = {};
  	$scope.order.upliftDate = '';
  	$scope.data = {};
  	$scope.aircraft = {};
  	$scope.data.activate = true;
  	$scope.showLoader = true;
  	$scope.jetShow = [];
  	$scope.marginShow = [];
  
  	$scope.jetShow[0] = true;
  	$scope.marginShow[0] = true;
  	$scope.dispatchOrder = {};
  	$scope.dispatchOrder.fuelOrderList = [];
  	$scope.statusFilterOptions = [];
  	$scope.companyList = {};
  	$scope.statusFilterOptions.push({
  		'id' : '',
  		'title' : 'Show All'
  	}, {
  		'id' : 'pending',
  		'title' : 'Pending'
  	}, {
  		'id' : 'invoiced',
  		'title' : 'Invoiced'
  	}, {
  		'id' : 'paid',
  		'title' : 'Paid'
  	}, {
  		'id' : 'cancelled',
  		'title' : 'Cancelled'
  	}, {
  		'id' : 'archived',
  		'title' : 'Archived'
  	}
  
  	);
9d840540f   Anchit Jindal   fixed bugs and ne...
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  	/*function getAllCompanies(){
  	  CustomersService.getAllCompanies().then(function(result) {
  	    $scope.companyList = result;
  	    for(var i=0; i<$scope.companyList.length; i++){
  	      $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id;
  	    }
  	  })
  
  	}*/
  
  	$scope.statusFilter = [
  		{
  			id : "",
  			title : "Show All"
  		},
  		{
  			id : "true",
  			title : "Active"
  		},
  		{
  			id : "false",
  			title : "Inactive"
  		}
  	]
  
  	function getAllCompanies() {
  		CustomersService.getAllCompanies().then(function(result) {
9d840540f   Anchit Jindal   fixed bugs and ne...
79
  			$scope.companyList = result;
2a564fddb   Kuldeep Arora   minor
80
  			//console.log("result",result)
9d840540f   Anchit Jindal   fixed bugs and ne...
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
  			for (var i = 0; i < $scope.companyList.length; i++) {
  				if ($scope.companyList[i].companyContact != null) {
  					if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) {
  						$scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber;
  					}
  				}
  				if ($scope.companyList[i].primaryContact != null) {
  					if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) {
  						$scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName;
  					}
  				}
  				if ($scope.companyList[i].margin != null) {
  					if ($scope.companyList[i].margin.marginName != null) {
  						$scope.companyList[i].masterMargin = $scope.companyList[i].margin.id;
  					}
  				}
  			}
  			$scope.displayCompanyList = new NgTableParams({
  				page : 1,
  				count : 10,
  			}, {
  				data : $scope.companyList
  			});
  			$scope.showLoader = false;
  		})
  	}
d1e8d9afb   Kuldeep Arora   fuel order & home...
107
  	getAllCompanies();
9d840540f   Anchit Jindal   fixed bugs and ne...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
  	$scope.editMargin = function(customer) {
  		//console.log('customer', customer);
  		$scope.showLoader = true;
  		event.stopPropagation();
  
  		var companyMargin = "companyName=" + customer.companyName + "&masterMargin=" + customer.masterMargin
  		+ "&addressOne=" + customer.addressOne + "&addressTwo=" + customer.addressTwo + "&city=" + customer.city + "&state="
  		+ customer.state + "&country=" + customer.country + "&zipcode=" + customer.zipcode + "&internalNote="
  		+ customer.internalNote + "&certificateType=" + customer.certificateType + "&baseTenant=" + customer.baseTenant
  		+ "&fuelerlinxCustomer=" + customer.fuelerlinxCustomer + "&contractFuelVendor=" + customer.contractFuelVendor
  		+ "&activate=" + customer.activate + "&baseIcao=" + customer.baseIcao + "&companyId=" + customer.id;
  
  		ViewCompanyService.updateCompany(companyMargin).then(function(result) {
  			if (result != null && result.success) {
  				$scope.showLoader = false;
  				toastr.success('' + result.success + '', {
  					closeButton : true
  				})
  				getAllCompanies();
  			} else {
  				$scope.showLoader = false;
  				toastr.error('' + result.statusText + '', {
  					closeButton : true
  				})
  			}
  		})
  	}
  
  	getData();
  	function getData() {
  		$scope.showLoader = true;
  		CustomersService.getAircraftMake().then(function(result) {
87660da6c   Kuldeep Arora   testing
140
  			//console.log("==aircrafts===",result)
9d840540f   Anchit Jindal   fixed bugs and ne...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
  			$scope.aircraftMakeList = result;
  			$scope.showLoader = false;
  		})
  	}
  	// CustomersService.getMargin().then(function(result) {
  	//   $scope.marginList = result;
  	// })
  	$scope.marginFilterOptions = [];
  	CustomersService.getJetMargin($scope.userProfileId).then(function(result) {
  		$scope.showLoader = true;
  		$scope.jetMarginList = result;
  		//console.log("jet margin",result,$scope.userProfileId)
  		$scope.marginFilterOptions.push({
  			'id' : '',
  			'title' : 'Show All'
  		});
  		for (var i = 0; i < result.length; i++) {
  			$scope.marginFilterOptions.push({
  				'id' : result[i].id,
  				'title' : result[i].marginName
  			})
  		}
  		$scope.showLoader = false;
  	})
  
  	CustomersService.getAvgMargin($scope.userProfileId).then(function(result) {
  		$scope.avgsMarginList = result;
  	// console.log('avgsMarginList',result)
  	})
  
  
  	$scope.showCompanyError = false;
  	$scope.showMarginError = false;
  
  	$scope.removeValidation = function() {
  		$scope.showCompanyError = false;
  		$('.companyNameInput').removeClass('customErrorInput');
  		if ($scope.data.companyName == 'undefined' || $scope.data.companyName == '') {
  			$('.companyNameInput').addClass('customErrorInput');
  			$scope.showCompanyError = true;
  		}
  	}
  
  	$scope.removeMarginValidation = function() {
  		$scope.showMarginError = false;
  		$('.marginSelectBox').removeClass('customErrorInput');
  	}
  
  	var companyData;
  	$scope.addFirstData = function(sel, step) {
  		$scope.showLoader = true;
  		if ($scope.data.companyName == undefined) {
  			$scope.showCompanyError = true;
  			$('.companyNameInput').addClass('customErrorInput');
  		} else if ($scope.data.masterMargin == undefined) {
  			$scope.showMarginError = true;
  			$('.marginSelectBox').addClass('customErrorInput');
  		} else {
  			$scope.aircraftDetails = [ {
  				'tail' : '',
  				'make' : '',
  				'model' : '',
  				'sizeId' : '',
  				'marginId' : $scope.data.masterMargin,
  				'avgasMarginId' : $scope.data.avgasMargin
  			} ];
  
  			$(sel).trigger('next.m.' + step);
  			getData();
  		}
  		$scope.showLoader = false;
  	}
4ecd206b2   Kuldeep Arora   Adding company/ai...
213

9d840540f   Anchit Jindal   fixed bugs and ne...
214
215
216
217
218
219
220
221
222
223
224
225
  	$scope.addNew = function() {
  		$scope.showLoader = true;
  		$scope.aircraftDetails.push({
  			'tail' : '',
  			'make' : '',
  			'model' : '',
  			'sizeId' : '',
  			'marginId' : $scope.data.masterMargin,
  			'avgasMarginId' : $scope.data.avgasMargin
  		});
  		$scope.showLoader = false;
  	};
4ecd206b2   Kuldeep Arora   Adding company/ai...
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
  		$scope.aircraftIdx = '';
          $scope.checkTail = function(tail, idx){
          	var data = "tail=" + tail;
          	$scope.aircraftIdx = idx;
          	CustomersService.checkTailRegistration(data).then(function(result) {
                  if(result.error) {
                  	$scope.aircraftMessage = result.error;
                  	$scope.openAddAirCraftError();
                  } else if(result.warning) {
                  	$scope.aircraftMessage = result.warning;
                  	$scope.openAddAirCraftWarning();
                  }
              })
          }
  
      $scope.openAddAirCraftError = function() {
      	$('#addAirCraftError').css('display', 'block');
      }
      
      $scope.openAddAirCraftWarning = function() {
     	 	$('#addAirCraftWarning').css('display', 'block');
      }
  	 $scope.acceptAirCraftError = function() {
      	$('#addAirCraftWarning').css('display', 'none');
      }
  	    
      $scope.cancelAirCraftError = function() {
      	$scope.aircraftDetails[$scope.aircraftIdx].tail = '';
      	$('#addAirCraftWarning').css('display', 'none');
      	$('#addAirCraftError').css('display', 'none');
      }
  
  
  	/*$scope.getModal = function(makeId, index) {
9d840540f   Anchit Jindal   fixed bugs and ne...
260
  		$scope.showLoader = true;
9d840540f   Anchit Jindal   fixed bugs and ne...
261
262
263
  		CustomersService.getModal($scope.aircraft.make).then(function(result) {
  			$scope.showLoader = false;
  			$scope.aircraftDetails[index].aircraftModalList = result;
9d840540f   Anchit Jindal   fixed bugs and ne...
264
  		})
4ecd206b2   Kuldeep Arora   Adding company/ai...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
  	}*/
  	 $scope.getModal = function(makeId, index) {
              $scope.showLoader = true;
              $scope.aircraft.make = makeId;
              CustomersService.getModal($scope.aircraft.make).then(function(result) {
                  $scope.showLoader = false;
                  $scope.aircraftDetails[index].aircraftModalList = result;
              })
          }
          
  
      	 $scope.selectedOption = '';
  	    $scope.getSize = function(model, index) {
  	        $scope.showLoader = true;
  	        $scope.aircraft.model = model;
  	        CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) {
  	            $scope.showLoader = false;
  	            $scope.aircraftDetails[index].aircraftSizeList = result;
0a364e561   Kuldeep Arora   minor
283
  	            $scope.getFuelType($scope.aircraftDetails[index].aircraftSizeList[0].aircraftSize.id,index);
4ecd206b2   Kuldeep Arora   Adding company/ai...
284
285
286
  	            
  	        })
  	    }
9d840540f   Anchit Jindal   fixed bugs and ne...
287

4ecd206b2   Kuldeep Arora   Adding company/ai...
288
  	/*$scope.getSize = function(model, index) {
9d840540f   Anchit Jindal   fixed bugs and ne...
289
290
291
292
293
  		$scope.showLoader = true;
  		CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) {
  			$scope.showLoader = false;
  			$scope.aircraftDetails[index].aircraftSizeList = result;
  		})
4ecd206b2   Kuldeep Arora   Adding company/ai...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
  	}*/
  
  	 $scope.getFuelType = function(size, index) {
          	$scope.showLoader = true;
          	var data = "model="+$scope.aircraft.model+"&make="+$scope.aircraft.make+"&sizeId="+size;
          	ViewCompanyService.checkFuelType(data).then(function(result){
                $scope.showLoader = false;
                if (result.type == "JetA") {
                    $scope.jetShow[index] = false;
                    $scope.marginShow[index] = true;
                } else if (result.type == "Avgas")   {
                    $scope.jetShow[index] = true;
                    $scope.marginShow[index] = false;
                }else {
                    $scope.jetShow[index] = true;
                    $scope.marginShow[index] = true;
                }
          	})
          }
9d840540f   Anchit Jindal   fixed bugs and ne...
313
314
315
  
  	$scope.aircraftListData = {};
  	$scope.addData = [];
4ecd206b2   Kuldeep Arora   Adding company/ai...
316
317
318
319
  	 $scope.tailArray = [];
      function check(array){
          return (new Set(array)).size !== array.length;
      }
9d840540f   Anchit Jindal   fixed bugs and ne...
320
  	$scope.saveCompanyData = function() {
4ecd206b2   Kuldeep Arora   Adding company/ai...
321
  	//	console.log("company data --",$scope.data)
9d840540f   Anchit Jindal   fixed bugs and ne...
322
  		CustomersService.addCompany($scope.data).then(function(result) {
4ecd206b2   Kuldeep Arora   Adding company/ai...
323
324
  			$scope.tailArray = [];
  			$scope.addData =[];
9d840540f   Anchit Jindal   fixed bugs and ne...
325
326
327
328
329
330
331
332
333
334
335
336
  			$scope.accountId = result;
  			$scope.aircraft.accountId = $scope.accountId;
  
  			for (var i = 0; i < $scope.aircraftDetails.length; i++) {
  				$scope.addData.push({
  					'tail' : $scope.aircraftDetails[i].tail,
  					'make' : $scope.aircraftDetails[i].make,
  					'model' : $scope.aircraftDetails[i].model,
  					'sizeId' : $scope.aircraftDetails[i].sizeId,
  					'marginId' : $scope.aircraftDetails[i].marginId,
  					'avgasMarginId' : $scope.aircraftDetails[i].avgasMarginId
  				});
4ecd206b2   Kuldeep Arora   Adding company/ai...
337
  				 $scope.tailArray.push($scope.aircraftDetails[i].tail);
9d840540f   Anchit Jindal   fixed bugs and ne...
338
  			}
4ecd206b2   Kuldeep Arora   Adding company/ai...
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
  			
  			 if (check($scope.tailArray)) {
                      toastr.error('Duplicate Tail Added.', {
                                  closeButton: true
                              })
                  }else{
  					$scope.aircraftListData.aircraftList = $scope.addData;
  					$scope.aircraftListData.accountId = $scope.aircraft.accountId;
  					/*if ($scope.aircraftListData.aircraftList[0].tail == "" || $scope.aircraftListData.aircraftList[0].make == null || $scope.aircraftListData.aircraftList[0].model == null) {
  						$scope.aircraftListData.aircraftList = [];
  					}*/
  
  					CustomersService.addAircraft($scope.aircraftListData).then(function(result) {
  
  						if (result != null && result.success) {
  	
  							toastr.success('' + result.success + '', {
  								closeButton : true
  							})
  							 $('#demo-modal-3').css('display', 'none');
  		                     $('.modal-backdrop').css('display', 'none');
  							getAllCompanies();
  							location.reload();
  						} else {
  							toastr.error('' + result.statusText + '', {
  								closeButton : true
  							})
  						}
  					});
9d840540f   Anchit Jindal   fixed bugs and ne...
368
  				}
9d840540f   Anchit Jindal   fixed bugs and ne...
369
370
371
372
373
374
  		})
  	}
  
  	/*add a fuel order*/
  	$scope.getOrders = function() {
  		fuelOrdersService.getOrders().then(function(result) {
9d840540f   Anchit Jindal   fixed bugs and ne...
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
  			$scope.orderdata = result;
  			for (var i = 0; i < $scope.orderdata.length; i++) {
  				$scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate);
  
  				// var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear()
  				var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear()
  				//  str = str.slice(4,16)
  				$scope.orderdata[i].upliftDateString = str
  				// console.log(str);
  
  			}
  
  			$scope.displayFuelOrderList = new NgTableParams({
  				page : 1,
  				count : 10,
  			}, {
  				data : $scope.orderdata
  			});
  			$(document).ready(function() {
  				var myselect = document.getElementsByClassName('colorfulSelectbox');
  
  				for (var i = 0; i < myselect.length; i++) {
  					var colourIndex = $(myselect[i]).prop('selectedIndex');
  					colourIndex = colourIndex + 1;
  					// console.log(colourIndex);
  					var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color');
  					$(myselect[i]).css('background-color', getColor);
  					// console.log('colour', getColor);
  					myselect[i].blur();
  				}
  
  			})
  
  		})
  	}
  
  	$scope.getOrders();
  	$scope.tiervalue=function(){
  		$scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak;
  	}
  
  	$scope.setCost = function(cost){
  		if(cost != null) {
  			var obj =JSON.parse(cost);
  			$scope.order.fboCost = obj.cost;
  		}
  	}
  
  	$scope.cancelOrder = function() {
  		$scope.order = {};
  	}
  	
  	$scope.dispatchFuel = function(){
91d8ce8f4   Kuldeep Arora   customer grid bug...
428
429
430
431
432
433
434
435
  		    $scope.showLoader = true;
  	        $scope.fuelData = {};
  	        $scope.fuelData.companyId = $scope.selectedCompanyId;
  	        $scope.fuelData.companyName =$scope.order.defaultCompanyName; 
  	        var aircraftObj =JSON.parse($scope.order.aircraftName);
  	        $scope.fuelData.aircraftName = aircraftObj.tail;
  	        $scope.fuelData.make = aircraftObj.make;
  	        $scope.fuelData.model = aircraftObj.model;
20f645d6f   Kuldeep Arora   fuelorder
436
  	        //$scope.fuelData.fuelOn = $scope.order.fuelOn;
91d8ce8f4   Kuldeep Arora   customer grid bug...
437
438
  	        $scope.fuelData.invoiced = $scope.order.invoiced;
  	        $scope.fuelData.volume = $scope.order.volume; 
0173d74ad   Kuldeep Arora   source autopopula...
439
  	       // $scope.fuelData.source = $scope.order.source; 
91d8ce8f4   Kuldeep Arora   customer grid bug...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
  	       
  	        $scope.fuelData.total = $scope.order.total;
  	        //tier no use
  	        $scope.fuelData.tierBreak = $scope.order.tierBreak;
  
  	        var obj =JSON.parse($scope.order.priceQuote);
  	        $scope.fuelData.priceQuote = obj.papTotal;
  	        $scope.fuelData.fboCost = obj.cost;
  	        $scope.fuelData.productName = obj.productName;
  
  	        $scope.fuelData.etaTime = $scope.order.etaTime;
  	        $scope.fuelData.etdTime = $scope.order.etdTime;
  	        $scope.fuelData.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.fuelData.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.fuelData.departingDate = $scope.order.departingDate.getTime();
  	        }
  	          
  	        if($scope.order.status === null || $scope.order.status === undefined){
  
  	            $scope.fuelData.status = "pending"; //default status
  
  	          }else {
  	            
  	             $scope.fuelData.status = $scope.order.status;
  	          } 
20f645d6f   Kuldeep Arora   fuelorder
478
479
480
481
482
            	if($scope.fuelData.fuelOn === null || $scope.fuelData.fuelOn ===undefined){
                    $scope.fuelData.fuelOn = "Arrival"; //default fuelon
                  }else {
                    $scope.fuelData.fuelOn = $scope.order.fuelOn ;
                  }	
0173d74ad   Kuldeep Arora   source autopopula...
483
            	 if($scope.baseTenant && $scope.contractFuelVendor ){
6c795a9f9   Kuldeep Arora   tenant/caa status...
484
                  $scope.fuelData.source = "Tenant/CAA" ;
0173d74ad   Kuldeep Arora   source autopopula...
485
486
487
488
489
490
                }else if($scope.baseTenant)
                {
                  $scope.fuelData.source = "Tenant/Base Customer";
                }else if($scope.contractFuelVendor){
                  $scope.fuelData.source = "CAA Member";
                }
91d8ce8f4   Kuldeep Arora   customer grid bug...
491
              $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
0173d74ad   Kuldeep Arora   source autopopula...
492
               //console.log("=====$scope.fueldata======",$scope.fuelData)
91d8ce8f4   Kuldeep Arora   customer grid bug...
493
494
495
496
497
498
499
500
501
502
              fuelOrdersService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
                  $scope.showLoader = false;
                  $scope.order = {};
                  $scope.dispatchOrder.fuelOrderList = [];
                  $('#demo-modal-4').css('display', '');
                  $scope.getOrders();
                  toastr.success('Fuel Order Dispatched Successfully', {
                          closeButton: true
                        })
            }) 
9d840540f   Anchit Jindal   fixed bugs and ne...
503
504
505
  	}
  
  	$scope.addTotal = function(value, valueOf) {
87660da6c   Kuldeep Arora   testing
506
507
  		if (value != undefined && valueOf != undefined) {
  			value = JSON.parse(value)
39a850f31   Kuldeep Arora   total calculation
508
  			$scope.order.total = Math.abs(value.papTotal) * valueOf; 
9d840540f   Anchit Jindal   fixed bugs and ne...
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
  		}
  	}
  
  	$scope.getAircraft = function(company) {
  		$scope.selectedCompanyName = company;
  		//$scope.showLoader = true;
  		//  console.log("id",company)
  		for (var i = 0; i < $scope.companyList.length; i++) {
  			if ($scope.companyList[i].companyName == company) {
  				if ($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null) {
  					fuelOrdersService.getFuelCost($scope.companyList[i].id).then(function(margins) {
  						$scope.marginList = margins;
  					//console.log('$scope.marginList', $scope.marginList);
  					})
  				} else if ($scope.companyList[i].margin != null || $scope.companyList[i].marginAVGAS == null) {
  					fuelOrdersService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) {
  						$scope.marginList = margins;
  					})
  				} else if ($scope.companyList[i].margin == null || $scope.companyList[i].marginAVGAS != null) {
  					fuelOrdersService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) {
  						$scope.marginList = margins;
  					})
  				}
  				$scope.selectedCompanyId = $scope.companyList[i].id;
  				$scope.marginId = $scope.companyList[i].margin.id;
  				if ($scope.selectedCompanyId != '') {
  					fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) {
  						$scope.aircraftList = aircraft;
4ecd206b2   Kuldeep Arora   Adding company/ai...
537
  						//console.log("===tail search====",aircraft);
9d840540f   Anchit Jindal   fixed bugs and ne...
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
  					})
  				}
  				if ($scope.marginId != '') {
  					fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) {
  						$scope.tierList = tiers;
  					//              $scope.showLoader = false;
  					})
  				} else {
  					//  $scope.showLoader = false;
  				}
  			}
  		}
  
  	}
  
  	$scope.sourceList = [ {
  		source : "Direct Jet-A"
  	}, {
  		source : "Direct AVGAS 100LL"
  	} ];
  	$scope.cancelData = function() {
  		$scope.order = {};
  		$('#demo-modal-4').css('display', '');
  	}
0173d74ad   Kuldeep Arora   source autopopula...
562
  	$scope.setFuel = function(companyName,baseTenant,contractFuelVendor,fuelerlinxCustomer,certificateType) {
9d840540f   Anchit Jindal   fixed bugs and ne...
563
  		$('#demo-modal-4').css('display', 'block');
91d8ce8f4   Kuldeep Arora   customer grid bug...
564
  		$scope.order.defaultCompanyName = companyName;
0173d74ad   Kuldeep Arora   source autopopula...
565
566
567
568
569
  		$scope.order.certificateType = certificateType;
  		$scope.baseTenant = baseTenant;
  		$scope.contractFuelVendor = contractFuelVendor;
  		$scope.fuelerlinxCustomer = fuelerlinxCustomer;
  		//console.log("===values of checkbox===",baseTenant,contractFuelVendor,fuelerlinxCustomer) 
91d8ce8f4   Kuldeep Arora   customer grid bug...
570
  		$scope.getAircraft(companyName);
9d840540f   Anchit Jindal   fixed bugs and ne...
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
  	//  event.stopPropagation();
  	//  $state.go('app.updateFuelManager');
  	}
  
  	/*  ng table  */
  
  	$scope.exportCompany = function() {
  		$scope.showLoader = true;
  		var fileName = "companies.csv";
  		var a = document.createElement("a");
  		document.body.appendChild(a);
  		CustomersService.exportCompany().then(function(result) {
  			var file = new Blob([ result ], {
  				type : 'application/csv'
  			});
  			var fileURL = URL.createObjectURL(file);
  			a.href = fileURL;
  			a.download = fileName;
  			a.click();
  			$scope.showLoader = false;
  		})
  	}
  	getCompanyName();
  	function getCompanyName() {
  		CustomersService.getCompanyName().then(function(result) {
  			$scope.compNameList = result;
  		//console.log("kd",result)
  		})
  	}
4ecd206b2   Kuldeep Arora   Adding company/ai...
600
601
  	// old api not use
  	/*$scope.checkJetWithTail = function(tail, index) {
9d840540f   Anchit Jindal   fixed bugs and ne...
602
  		ViewCompanyService.checkJetType(tail).then(function(result) {
9d840540f   Anchit Jindal   fixed bugs and ne...
603
604
605
606
607
608
609
610
  			if (result.jetA == "true") {
  				$scope.jetShow[index] = false;
  				$scope.marginShow[index] = true;
  			} else {
  				$scope.jetShow[index] = true;
  				$scope.marginShow[index] = false;
  			}
  		})
4ecd206b2   Kuldeep Arora   Adding company/ai...
611
  	}*/
9d840540f   Anchit Jindal   fixed bugs and ne...
612

91d8ce8f4   Kuldeep Arora   customer grid bug...
613
614
615
616
617
618
619
620
621
622
623
624
625
   $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"},];
9d840540f   Anchit Jindal   fixed bugs and ne...
626
  }