flightDept.controller.js
3.5 KB
1
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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'use strict';
//Load controller
angular.module('acuefuel')
.controller('FlightDeptController', function ($scope, $uibModal, FBOFlight) {
$scope.data = {};
$scope.user = {};
$scope.aircraft = {};
$scope.userData = function(){
if($scope.status == true){
$scope.user.status = 'active';
}else{
$scope.user.status = 'inactive';
}
$scope.user.username = $scope.user.email;
$scope.user.userType = 'flightDetp';
console.log($scope.user)
var formdata = "companyName=" + $scope.user.companyName + "&email=" + $scope.user.email + "&username=" + $scope.user.username + "&firstName=" + $scope.user.firstName + "&lastName=" + $scope.user.lastName + "&password=" + $scope.user.password + "&phone=" + $scope.user.phone + "&mobile=" + $scope.user.mobile + "&status=" + $scope.user.status + "&userType=" + $scope.user.userType + "&clientNote=" + $scope.user.clientNote;
FBOFlight.registerUser(formdata).then(function(result) {
$scope.registerId = result;
$scope.data.accountId = $scope.registerId;
$scope.aircraft.accountId = $scope.registerId;
toastr.success('Created Successfully', {
closeButton: true
})
})
}
$scope.data.cardType = 'creditCard';
var cardData = {}
cardData.paymentMethodList = [];
$scope.addCard = function(){
cardData.paymentMethodList.push($scope.data);
console.log("cardData", cardData);
FBOFlight.addCardInformation(cardData).then(function(result) {
console.log(result)
toastr.success('Created Successfully', {
closeButton: true
})
})
}
getData();
function getData(){
FBOFlight.getAircraftMake().then(function(result) {
$scope.aircraftMakeList = result;
$scope.aircraft.make = $scope.aircraftMakeList[0];
FBOFlight.getModal($scope.aircraft.make).then(function(result) {
$scope.aircraftModalList = result;
$scope.aircraft.model = $scope.aircraftModalList[0];
})
})
FBOFlight.getAircraftSize().then(function(result) {
$scope.aircraftSizeList = result;
$scope.aircraft.size = $scope.aircraftSizeList[0];
})
}
$scope.getModal = function(){
var modelId = $scope.aircraft.make
FBOFlight.getModal(modelId).then(function(result) {
$scope.aircraftModalList = result;
$scope.aircraft.model = $scope.aircraftModalList[0];
})
}
$scope.aircraftData = {};
$scope.aircraftData.aircraftList = [];
$scope.getCraftList = [];
$scope.addAircraft = function(){
$scope.aircraftData.aircraftList.push($scope.aircraft);
console.log($scope.aircraftData.aircraftList)
if ($scope.getCraftList.indexOf($scope.aircraft) == -1) {
$scope.getCraftList.push($scope.aircraft);
}
FBOFlight.addAircraft($scope.aircraftData).then(function(result) {
$('#myModal4').modal('hide');
$scope.reset();
toastr.success('Created Successfully', {
closeButton: true
})
})
}
$scope.reset = function() {
$scope.aircraft = {};
$scope.aircraft.accountId = $scope.data.accountId;
$scope.aircraftData.aircraftList = [];
getData();
}
});