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