Blame view
app/views/fbo-flight/flightDept.controller.js
5.33 KB
e4e496d13
|
1 2 3 |
'use strict'; //Load controller |
9835dbe3e
|
4 |
angular.module('acuefuel') |
e4e496d13
|
5 |
|
d5fb510e5
|
6 |
.controller('FlightDeptController', function ($scope, $uibModal, FBOFlight) { |
db8e1f992
|
7 8 9 10 11 |
$scope.showCompany = true; $scope.editName = function(){ $scope.showCompany = false; } |
0a4eb77cc
|
12 |
$scope.data = {}; |
5c6477d3d
|
13 |
$scope.user = {}; |
104d51edf
|
14 |
$scope.aircraft = {}; |
5c6477d3d
|
15 |
$scope.userData = function(){ |
db8e1f992
|
16 17 18 19 20 21 22 23 24 |
if($scope.user.email == undefined || $scope.user.email == null){ toastr.error('Please enter your email first', { closeButton: true }) }else if($scope.user.firstName == undefined || $scope.user.firstName == null){ toastr.error('Please enter your First Name', { closeButton: true }) }else{ |
5c6477d3d
|
25 26 27 28 29 30 31 32 |
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) |
d5fb510e5
|
33 |
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; |
7379f005b
|
34 35 36 |
FBOFlight.registerUser(formdata).then(function(result) { $scope.registerId = result; $scope.data.accountId = $scope.registerId; |
104d51edf
|
37 38 39 40 |
$scope.aircraft.accountId = $scope.registerId; toastr.success('Created Successfully', { closeButton: true }) |
db8e1f992
|
41 |
$state.go('index.flightDept'); |
1956e3844
|
42 43 44 45 46 |
}, function (err) { toastr.error('Error in registering', { closeButton: true }) }); |
db8e1f992
|
47 |
} |
5c6477d3d
|
48 |
} |
0a4eb77cc
|
49 50 |
$scope.data.cardType = 'creditCard'; |
7379f005b
|
51 52 53 |
var cardData = {} cardData.paymentMethodList = []; $scope.addCard = function(){ |
1956e3844
|
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
if($scope.aircraft.accountId == undefined){ toastr.error('Please Add Contact Information', { closeButton: true }) }else{ cardData.paymentMethodList.push($scope.data); console.log("cardData", cardData); FBOFlight.addCardInformation(cardData).then(function(result) { console.log(result) toastr.success('Created Successfully', { closeButton: true }) }) } |
104d51edf
|
69 70 71 72 73 74 75 76 77 78 |
} 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]; |
db8e1f992
|
79 80 81 82 |
FBOFlight.getAircraftSize($scope.aircraft.make, $scope.aircraft.model).then(function(result) { $scope.aircraftSizeList = result; $scope.aircraft.size = $scope.aircraftSizeList[0]; }) |
104d51edf
|
83 84 85 |
}) }) |
7379f005b
|
86 |
} |
104d51edf
|
87 |
|
d5fb510e5
|
88 |
|
104d51edf
|
89 |
$scope.getModal = function(){ |
db8e1f992
|
90 91 |
var makeId = $scope.aircraft.make; FBOFlight.getModal(makeId).then(function(result) { |
104d51edf
|
92 93 |
$scope.aircraftModalList = result; $scope.aircraft.model = $scope.aircraftModalList[0]; |
db8e1f992
|
94 95 96 97 98 99 100 101 102 103 104 |
FBOFlight.getAircraftSize(makeId, $scope.aircraft.model).then(function(result) { $scope.aircraftSizeList = result; $scope.aircraft.size = $scope.aircraftSizeList[0]; }) }) } $scope.getSize = function(){ FBOFlight.getAircraftSize($scope.aircraft.make, $scope.aircraft.model).then(function(result) { $scope.aircraftSizeList = result; $scope.aircraft.size = $scope.aircraftSizeList[0]; |
104d51edf
|
105 106 |
}) } |
1956e3844
|
107 108 109 110 111 112 |
$scope.openModal = function(){ if($scope.aircraft.accountId == undefined){ toastr.error('Please Add Contact Information', { closeButton: true }) |
db8e1f992
|
113 |
$('#myModal4').modal('show'); |
1956e3844
|
114 115 116 117 118 |
}else{ $('#myModal4').modal('show'); } } |
104d51edf
|
119 120 121 122 123 |
$scope.aircraftData = {}; $scope.aircraftData.aircraftList = []; $scope.getCraftList = []; $scope.addAircraft = function(){ $scope.aircraftData.aircraftList.push($scope.aircraft); |
104d51edf
|
124 125 |
if ($scope.getCraftList.indexOf($scope.aircraft) == -1) { $scope.getCraftList.push($scope.aircraft); |
104d51edf
|
126 127 128 129 130 131 132 133 |
} FBOFlight.addAircraft($scope.aircraftData).then(function(result) { $('#myModal4').modal('hide'); $scope.reset(); toastr.success('Created Successfully', { closeButton: true }) |
db8e1f992
|
134 135 136 137 138 139 140 |
}, function (err) { toastr.error('Error in Adding Aircraft', { closeButton: true }) $('#myModal4').modal('hide'); $scope.getCraftList.splice($scope.aircraft); }); |
1956e3844
|
141 |
|
104d51edf
|
142 143 144 145 146 147 148 149 |
} $scope.reset = function() { $scope.aircraft = {}; $scope.aircraft.accountId = $scope.data.accountId; $scope.aircraftData.aircraftList = []; getData(); } |
5c6477d3d
|
150 |
}); |