Blame view

app/partials/enterFuelOrder/enterFuelOrder.controller.js 2.5 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
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
52
53
54
55
56
  	$scope.order.upliftDate = '';
  	$scope.order.departingDate = '';
  	$scope.selectedCompanyName = '';
  	$scope.selectedCompanyId = '';
  	$scope.marginId = '';
  
  	enterFuelOrderService.getFuelPricingNew().then(function(margins) {
  		$scope.marginList = margins;
  		//console.log('$scope.marginList', $scope.marginList);
  	})
  
  	$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) {
  				$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;
  				}
  			}
  		}
  
  	}
  
  	$scope.dispatchFuel = function(){
e95d89b77   Swarn Singh   integrate editor ...
57
  		$scope.showLoader = true;
8f7dbe97c   Swarn Singh   fuel order comple...
58
59
60
61
62
63
64
65
66
  		$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();
  		}
e95d89b77   Swarn Singh   integrate editor ...
67
  		$scope.dispatchOrder.fuelOrderList.push($scope.order);
a55ef20b5   Swarn Singh   schedular added
68
69
  		console.log('$scope.order', $scope.dispatchOrder);
  		enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
8f7dbe97c   Swarn Singh   fuel order comple...
70
  			console.log('result', result);
e95d89b77   Swarn Singh   integrate editor ...
71
72
73
74
75
  			$scope.showLoader = false;
  			$scope.order = {};
  			toastr.success('Fuel Order Dispatched Successfully', {
                closeButton: true
              })
8f7dbe97c   Swarn Singh   fuel order comple...
76
77
78
79
  		})
  	}
  
  }