Blame view
app/views/updateFBODept/updateFBODept.controller.js
11 KB
a80703599
|
1 2 3 4 |
'use strict'; //Load controller angular.module('acuefuel') |
089f3a3c2
|
5 |
.controller('updateFBODeptController', function($scope, $stateParams, $state, UpdateAllFBODept, UpdateAllFBO, FBOFlight, FBOAdmin) { |
2d8381335
|
6 7 8 |
$(document).ready(function(){ $('.fboflight').addClass('active'); }); |
104d51edf
|
9 10 |
$scope.showPayments = true; $scope.aircraft = {}; |
47e72f419
|
11 |
$scope.updateData = {}; |
a80703599
|
12 |
var userProfileID = $stateParams.id; |
a19001fdd
|
13 14 |
$scope.companyId; |
a80703599
|
15 |
UpdateAllFBODept.getALlFBOData(userProfileID).then(function(result) { |
f0315ea9b
|
16 |
// console.log(result) |
a19001fdd
|
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
$scope.user = result; // $scope.aircraft.accountId = result.account.id; $scope.user.userTypeId = result.userType.id; UpdateAllFBODept.getNotes(userProfileID).then(function(response) { $scope.user.clientNote = response[0].notes $scope.user.userNoteId = response[0].id; }) // $scope.feature = result.accountFeatureControl; // console.log($scope.feature,"dsdsdsds") if($scope.user.account.user.status == 'ACTIVE'){ $scope.status = true; }else { $scope.status = false; } |
a80703599
|
31 |
}) |
a19001fdd
|
32 33 |
UpdateAllFBODept.getAssociatedCompany(userProfileID).then(function(result) { |
f0315ea9b
|
34 |
// console.log('=======q===',result) |
a19001fdd
|
35 36 37 |
$scope.companyId = result.id; getCrafts(result.id); $scope.aircraft.accountId = result.id; |
a80703599
|
38 |
}) |
a19001fdd
|
39 40 41 |
function getCrafts(id){ UpdateAllFBODept.getAircrafts(id).then(function(response) { |
104d51edf
|
42 |
$scope.getCraftList = response; |
16fa2ad10
|
43 |
for(var i=0;i<$scope.getCraftList.length;i++){ |
a19001fdd
|
44 45 |
$scope.getCraftList[i].sizeId = $scope.getCraftList[i].compAircraftSize.id; $scope.getCraftList[i].size = $scope.getCraftList[i].compAircraftSize.size; |
16fa2ad10
|
46 |
} |
47e72f419
|
47 48 49 |
}) } |
104d51edf
|
50 51 52 53 54 55 |
UpdateAllFBODept.getPaymentMethod(userProfileID).then(function(response) { $scope.paymentList = response; }) $scope.openCard = function(payment){ |
f0315ea9b
|
56 |
//console.log(payment) |
104d51edf
|
57 58 59 60 61 62 63 64 65 66 67 68 |
$scope.showPayments = false; $scope.data = {}; $scope.data.cardNumber = payment.cardNumber; $scope.data.cardType = payment.cardType; $scope.data.expiryDate = payment.expiryDate; $scope.data.id = payment.id; $scope.data.accountId = payment.user.account.id; } var cardData = {} cardData.paymentMethodList = []; $scope.updateCard = function(){ |
f0315ea9b
|
69 |
// console.log($scope.data) |
104d51edf
|
70 |
cardData.paymentMethodList.push($scope.data); |
f0315ea9b
|
71 |
// console.log("cardData", cardData); |
104d51edf
|
72 |
UpdateAllFBODept.updatePaymentMethod(cardData).then(function(result) { |
f0315ea9b
|
73 |
// console.log(result) |
104d51edf
|
74 75 76 77 78 79 80 81 82 83 84 |
toastr.success('Updated Successfully', { closeButton: true }) $scope.reset(); }) } $scope.reset = function(){ cardData.paymentMethodList = []; } |
089f3a3c2
|
85 86 |
$scope.checkUsername = function(){ FBOAdmin.checkUsernameEmail($scope.user.email).then(function(status) { |
f0315ea9b
|
87 |
// console.log(status) |
089f3a3c2
|
88 89 90 91 92 93 94 |
if(status != 200){ toastr.error('This email has alreay taken', { closeButton: true }) } }) } |
104d51edf
|
95 |
$scope.userData = function(){ |
f0315ea9b
|
96 |
// console.log($scope.user.userTypeId) |
db8e1f992
|
97 98 99 100 101 102 103 104 105 |
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{ |
3433be3d6
|
106 |
if($scope.status == true){ |
104d51edf
|
107 108 109 110 111 112 |
$scope.user.status = 'active'; }else{ $scope.user.status = 'inactive'; } $scope.user.username = $scope.user.email; $scope.user.userType = 'flightDetp'; |
f0315ea9b
|
113 |
// console.log($scope.user) |
a4d4a8320
|
114 115 116 |
// if($scope.user.userNoteId == undefined){ // $scope.user.userNoteId = null; // } |
104d51edf
|
117 118 119 120 121 122 |
var updateData = "companyName=" + $scope.user.companyName + "&username=" + $scope.user.username + "&firstName=" + $scope.user.firstName + "&lastName=" + $scope.user.lastName + "&phone=" + $scope.user.phone + "&mobile=" + $scope.user.mobile + "&status=" + $scope.user.status + "&userType=" + $scope.user.userType + "&userNote=" + $scope.user.clientNote + "&userNoteId=" + $scope.user.userNoteId + "&userTypeId=" + $scope.user.userTypeId + "&userProfileId=" + userProfileID; UpdateAllFBO.updateUser(updateData).then(function(result) { toastr.success(''+result.success+'', { closeButton: true }) }) |
26e0d5d69
|
123 |
$state.go('index.flightDept'); |
db8e1f992
|
124 |
} |
104d51edf
|
125 126 127 128 129 130 131 132 133 134 |
} 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]; |
104d51edf
|
135 |
|
db8e1f992
|
136 137 |
FBOFlight.getAircraftSize($scope.aircraft.make, $scope.aircraft.model).then(function(result) { $scope.aircraftSizeList = result; |
16fa2ad10
|
138 |
$scope.aircraft.sizeId = $scope.aircraftSizeList[0].aircraftSize.id; |
db8e1f992
|
139 140 141 |
}) }) |
104d51edf
|
142 143 144 |
}) } |
104d51edf
|
145 146 |
$scope.getModal = function(){ |
db8e1f992
|
147 148 |
var makeId = $scope.aircraft.make FBOFlight.getModal(makeId).then(function(result) { |
104d51edf
|
149 150 |
$scope.aircraftModalList = result; $scope.aircraft.model = $scope.aircraftModalList[0]; |
db8e1f992
|
151 152 153 |
FBOFlight.getAircraftSize(makeId, $scope.aircraft.model).then(function(result) { $scope.aircraftSizeList = result; |
16fa2ad10
|
154 |
$scope.aircraft.sizeId = $scope.aircraftSizeList[0].aircraftSize.id; |
db8e1f992
|
155 |
}) |
104d51edf
|
156 157 |
}) } |
db8e1f992
|
158 159 160 161 |
$scope.getSize = function(){ FBOFlight.getAircraftSize($scope.aircraft.make, $scope.aircraft.model).then(function(result) { $scope.aircraftSizeList = result; |
f0315ea9b
|
162 |
// console.log($scope.aircraftSizeList) |
16fa2ad10
|
163 |
$scope.aircraft.sizeId = $scope.aircraftSizeList[0].aircraftSize.id; |
f0315ea9b
|
164 |
// console.log($scope.aircraft.sizeId) |
db8e1f992
|
165 166 |
}) } |
a19001fdd
|
167 168 |
|
104d51edf
|
169 |
$scope.addAircraft = function(){ |
a19001fdd
|
170 171 172 173 174 175 176 177 178 179 |
$scope.aircraftListData = {}; $scope.addData = []; $scope.aircraftListData.aircraftList= []; $scope.addData.push({ 'tail': $scope.aircraft.tail, 'make': $scope.aircraft.make, 'model': $scope.aircraft.model, 'sizeId' : $scope.aircraft.sizeId }); |
f0315ea9b
|
180 |
// console.log('$scope.addData',$scope.addData); |
a19001fdd
|
181 182 183 |
$scope.aircraftListData.aircraftList = $scope.addData; $scope.aircraftListData.accountId = $scope.companyId; |
f0315ea9b
|
184 |
// console.log($scope.aircraft) |
a19001fdd
|
185 |
//$scope.aircraftData.aircraftList.push($scope.aircraft); |
104d51edf
|
186 |
|
a19001fdd
|
187 |
FBOFlight.addAircraft($scope.aircraftListData).then(function(result) { |
104d51edf
|
188 |
$('#myModal4').modal('hide'); |
a19001fdd
|
189 |
getCrafts($scope.companyId); |
104d51edf
|
190 191 192 193 |
$scope.resetData(); toastr.success('Created Successfully', { closeButton: true }) |
db8e1f992
|
194 195 196 197 198 |
}, function (err) { toastr.error('Error in Adding Aircraft', { closeButton: true }) $('#myModal4').modal('hide'); |
f0315ea9b
|
199 200 |
// console.log("aircraf---",$scope.aircraft) // $scope.getCraftList.splice($scope.aircraft); |
db8e1f992
|
201 |
}); |
16fa2ad10
|
202 |
} |
104d51edf
|
203 |
|
47e72f419
|
204 205 206 207 208 209 |
$scope.closeModal = function(){ $("#myModal5").modal('hide'); $scope.resetData(); } $scope.update = function(airdata){ |
db8e1f992
|
210 |
$("#myModal5").modal('show'); |
47e72f419
|
211 |
$scope.aircraft = airdata; |
f0315ea9b
|
212 |
// console.log('--------$scope.companyId---',$scope.companyId); |
a19001fdd
|
213 |
$scope.aircraft.accountId = $scope.companyId; |
db8e1f992
|
214 |
|
47e72f419
|
215 216 |
FBOFlight.getModal($scope.aircraft.make).then(function(result) { $scope.aircraftModalList = result; |
db8e1f992
|
217 218 |
FBOFlight.getAircraftSize($scope.aircraft.make, $scope.aircraft.model).then(function(result) { $scope.aircraftSizeList = result; |
f0315ea9b
|
219 |
// console.log($scope.aircraftSizeList) |
16fa2ad10
|
220 |
$scope.aircraft.sizeId = $scope.aircraftSizeList[0].aircraftSize.id; |
db8e1f992
|
221 |
}) |
47e72f419
|
222 223 224 225 226 227 228 229 230 231 232 |
}) } $scope.updatecraftData = {}; $scope.updatecraftData.aircraftList = []; $scope.updateAircraftData = {}; $scope.updateAircraft = function(updateAircraft){ $scope.updateAircraftData.id = updateAircraft.id; $scope.updateAircraftData.make = updateAircraft.make; $scope.updateAircraftData.model = updateAircraft.model; |
16fa2ad10
|
233 |
$scope.updateAircraftData.sizeId = updateAircraft.sizeId; |
47e72f419
|
234 |
$scope.updateAircraftData.tail = updateAircraft.tail; |
a19001fdd
|
235 |
$scope.updateAircraftData.accountId = $scope.companyId; |
f0315ea9b
|
236 |
// console.log($scope.updateAircraftData) |
47e72f419
|
237 238 |
$scope.updatecraftData.aircraftList.push($scope.updateAircraftData); |
f0315ea9b
|
239 |
// console.log($scope.updatecraftData.aircraftList) |
47e72f419
|
240 241 242 243 |
UpdateAllFBODept.updateAircraft($scope.updatecraftData).then(function(result) { $('#myModal5').modal('hide'); $scope.resetData(); |
a19001fdd
|
244 |
getCrafts($scope.companyId); |
47e72f419
|
245 246 247 |
toastr.success('Updated Successfully', { closeButton: true }) |
db8e1f992
|
248 249 250 251 252 253 254 |
}, function (err) { toastr.error('Error in Updating Aircraft', { closeButton: true }) $('#myModal5').modal('hide'); $scope.getCraftList.splice($scope.aircraft); }); |
47e72f419
|
255 256 257 |
} $scope.remove = function(data){ |
f0315ea9b
|
258 |
//console.log(data) |
47e72f419
|
259 260 261 262 |
UpdateAllFBODept.removeAircraft(data.id).then(function(result) { toastr.success(''+result.success+'', { closeButton: true }) |
a19001fdd
|
263 |
getCrafts($scope.companyId); |
47e72f419
|
264 265 |
}) } |
104d51edf
|
266 267 |
$scope.resetData = function() { $scope.aircraft = {}; |
a19001fdd
|
268 269 |
$scope.aircraft.accountId = $scope.companyId; $scope.aircraftListData.aircraftList = []; |
104d51edf
|
270 271 |
getData(); } |
f0315ea9b
|
272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
var deleteFlightDeptUserId = ""; $scope.deleteData = function(userid){ $('#delete2').css('display', 'block'); //console.log("kd user id--",userid) deleteFlightDeptUserId = userid; } $scope.deleteUserData = function(){ // console.log("api hit") UpdateAllFBODept.deleteUser(deleteFlightDeptUserId).then(function(result) { $('#delete2').css('display', 'none'); if(result.success){ toastr.success(''+result.success+'', { closeButton: true }) }else{ toastr.error(''+result.statusText+'', { closeButton: true }) } $state.go('index.flightDept') }) } $scope.cancelDelete = function(){ $('#delete2').css('display', 'none'); } |
a80703599
|
302 |
}); |