Blame view

app/partials/enterFuelOrder/enterFuelOrder.controller.js 3.48 KB
8f7dbe97c   Swarn Singh   fuel order comple...
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   Swarn Singh   schedular added
18
  	$scope.dispatchOrder = {};
e95d89b77   Swarn Singh   integrate editor ...
19
  	$scope.dispatchOrder.fuelOrderList = [];
8f7dbe97c   Swarn Singh   fuel order comple...
20
21
22
23
24
  	$scope.order.upliftDate = '';
  	$scope.order.departingDate = '';
  	$scope.selectedCompanyName = '';
  	$scope.selectedCompanyId = '';
  	$scope.marginId = '';
8f7dbe97c   Swarn Singh   fuel order comple...
25
26
27
28
29
  	$scope.getAircraft = function(company){
  		$scope.selectedCompanyName = company;
  		$scope.showLoader = true;
  		for (var i = 0; i < $scope.companyList.length; i++) {
  			if ($scope.companyList[i].companyName == company) {
efcd5bfce   Anchit Jindal   minor changes
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  				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);
  					})
  				} else if ($scope.companyList[i].margin != null || $scope.companyList[i].marginAVGAS == null) {
  					enterFuelOrderService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) {
  						$scope.marginList = margins;
  			        })
  				} else if ($scope.companyList[i].margin == null || $scope.companyList[i].marginAVGAS != null) {
  					enterFuelOrderService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) {
  			        	$scope.marginList = margins;
  			        })
  				}
8f7dbe97c   Swarn Singh   fuel order comple...
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  				$scope.selectedCompanyId = $scope.companyList[i].id;
  				$scope.marginId = $scope.companyList[i].margin.id;
  				if ($scope.selectedCompanyId != '') {
  					enterFuelOrderService.getAircraft($scope.selectedCompanyId).then(function(aircraft) {
  						$scope.aircraftList = aircraft;
  					})
  				}
  				if ($scope.marginId != '') {
  					enterFuelOrderService.getJetTiers($scope.marginId).then(function(tiers) {
  		                $scope.tierList = tiers;
  		                $scope.showLoader = false;
  		            })
  				}else{
  					$scope.showLoader = false;
  				}
  			}
  		}
  
  	}
efcd5bfce   Anchit Jindal   minor changes
63
64
65
66
67
68
69
70
71
  	$scope.setCost = function(cost){
  		console.log(cost);
  		if(cost != null) {
  			var obj =JSON.parse(cost);
  			$scope.order.fboCost = obj.cost;
  		}
  			
  	}
  	
8f7dbe97c   Swarn Singh   fuel order comple...
72
  	$scope.dispatchFuel = function(){
e95d89b77   Swarn Singh   integrate editor ...
73
  		$scope.showLoader = true;
8f7dbe97c   Swarn Singh   fuel order comple...
74
75
76
77
78
79
80
81
82
  		$scope.order.companyId = $scope.selectedCompanyId;
  		if ($scope.order.upliftDate != '') {
  			$scope.order.upliftDate = new Date($scope.order.upliftDate);
  			$scope.order.upliftDate = $scope.order.upliftDate.getTime();
  		}
  		if ($scope.order.departingDate != '') {
  			$scope.order.departingDate = new Date($scope.order.departingDate);
  			$scope.order.departingDate = $scope.order.departingDate.getTime();
  		}
ae523d5ef   Mr. Hot Foods   account setting m...
83
84
85
  
  		$scope.order.status = 'Pending';
  		
efcd5bfce   Anchit Jindal   minor changes
86
87
88
89
  		console.log($scope.order.quotePrice);
  		var obj =JSON.parse($scope.order.priceQuote);
  		console.log('obj.papMargin',obj.papMargin);
  		$scope.order.priceQuote = obj.papMargin;
e95d89b77   Swarn Singh   integrate editor ...
90
  		$scope.dispatchOrder.fuelOrderList.push($scope.order);
a55ef20b5   Swarn Singh   schedular added
91
92
  		console.log('$scope.order', $scope.dispatchOrder);
  		enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
8f7dbe97c   Swarn Singh   fuel order comple...
93
  			console.log('result', result);
e95d89b77   Swarn Singh   integrate editor ...
94
95
96
97
98
  			$scope.showLoader = false;
  			$scope.order = {};
  			toastr.success('Fuel Order Dispatched Successfully', {
                closeButton: true
              })
8f7dbe97c   Swarn Singh   fuel order comple...
99
100
101
102
  		})
  	}
  
  }