Blame view
app/partials/viewCompany/viewCompany.controller.js
13.2 KB
feacde5ff
|
1 2 3 4 5 |
'use strict'; //Load controller angular.module('acufuel') |
28af27a3f
|
6 |
.controller('viewCompanyController', ['$scope','$uibModal', '$stateParams', 'ViewCompanyService', 'CustomersService', 'updateFuelManagerService', function($scope , $uibModal, $stateParams, ViewCompanyService, CustomersService, updateFuelManagerService) { |
55e075d7e
|
7 8 |
$scope.data = {}; $scope.data.priceEmail = true; |
b1f6160d4
|
9 |
$scope.aircraft = {}; |
3a9f4472b
|
10 |
$scope.primayData = {}; |
d24318592
|
11 |
$scope.showLoader = false; |
ba1d39503
![]() |
12 13 |
$scope.showLoader = true; $scope.showUpdateBtn = false; |
28af27a3f
|
14 |
$scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')); |
3a9f4472b
|
15 |
|
7152ff131
|
16 17 18 19 20 |
$(document).ready(function() { $("#reset").click(function() { $("input").val(""); }); }); |
3a9f4472b
|
21 22 23 |
CustomersService.getMargin().then(function(result) { $scope.marginList = result; }) |
48ed0c7bb
|
24 |
var value = ""; |
55e075d7e
|
25 |
var companyId = $stateParams.id; |
e9a2edf03
|
26 27 28 29 30 31 32 33 34 35 36 37 |
getCompanyDetail(); function getCompanyDetail(){ ViewCompanyService.getCompany(companyId).then(function(result) { $scope.companyData = result; if(result.margin != null){ $scope.companyData.masterMargin = result.margin.id; } $scope.showLoader = false; }) } |
55e075d7e
|
38 |
|
74c8ae4bb
|
39 |
$scope.changeCompanyStatus = function(){ |
3a9f4472b
|
40 41 |
var statusData = "status=" + $scope.companyData.activate; ViewCompanyService.changeStatus(companyId, statusData).then(function(result) { |
c555af312
|
42 43 44 45 46 |
if(result.success){ toastr.success(''+result.success+'', { closeButton: true }) } |
3a9f4472b
|
47 |
}) |
c555af312
|
48 |
} |
3a9f4472b
|
49 50 |
|
48ed0c7bb
|
51 52 53 54 55 56 |
getContactList(); function getContactList(){ ViewCompanyService.getContact(companyId).then(function(result) { $scope.companyContactList = result; }) } |
55e075d7e
|
57 |
|
b1f6160d4
|
58 59 60 61 62 63 64 |
getAircraftList(); function getAircraftList(){ ViewCompanyService.getAircraft(companyId).then(function(result) { $scope.contactAircraftList = result; }) } |
55e075d7e
|
65 66 67 68 69 |
$scope.contactData = {}; $scope.contactData.contactList = []; $scope.addContact = function(){ $scope.data.companyId = companyId; $scope.contactData.contactList.push($scope.data); |
55e075d7e
|
70 |
ViewCompanyService.addContact($scope.contactData).then(function(result) { |
3a9f4472b
|
71 72 73 74 75 |
console.log(result) if(result.status == 200){ // toastr.success(''+result.success+'', { // closeButton: true // }) |
55e075d7e
|
76 |
$('#contact-modal-3').modal('hide'); |
3a9f4472b
|
77 78 |
$scope.primayData.id = result.data; $scope.sendPrimaryContact(); |
48ed0c7bb
|
79 |
getContactList(); |
55e075d7e
|
80 81 82 83 84 85 86 |
}else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }) } |
feacde5ff
|
87 |
|
b1f6160d4
|
88 89 90 91 92 93 94 |
getData(); function getData(){ CustomersService.getAircraftMake().then(function(result) { $scope.aircraftMakeList = result; }) } |
a4884cfe7
|
95 96 97 |
$scope.clearAircrafts = function(){ $scope.aircraftDetails = []; $scope.aircraftDetails = [{ |
b1f6160d4
|
98 99 100 |
'tail':'', 'make': '', 'model': '', |
3a9f4472b
|
101 102 |
'sizeId' : '', 'marginId': '' |
b1f6160d4
|
103 |
}]; |
a4884cfe7
|
104 |
} |
b1f6160d4
|
105 |
|
a4884cfe7
|
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
$scope.addNew = function(){ $scope.aircraftDetails.push({ 'tail':'', 'make': '', 'model': '', 'sizeId' : '', 'marginId': '' }); console.log($scope.aircraftDetails) }; $scope.getModal = function(makeId, index){ $scope.showLoader = true; $scope.aircraft.make = makeId; //var makeId = makeId; CustomersService.getModal($scope.aircraft.make).then(function(result) { $scope.showLoader = false; $scope.aircraftDetails[index].aircraftModalList = result; //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; }) } |
b1f6160d4
|
127 |
|
a4884cfe7
|
128 |
$scope.getSize = function(model, index){ |
d24318592
|
129 |
$scope.showLoader = true; |
a4884cfe7
|
130 131 132 133 134 135 |
CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { $scope.showLoader = false; $scope.aircraftDetails[index].aircraftSizeList = result; //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0]; }) } |
b1f6160d4
|
136 |
|
a4884cfe7
|
137 138 139 140 141 142 143 144 145 146 147 148 |
$scope.aircraftListData = {}; //$scope.addData = []; $scope.saveCompanyData = function(){ for(var i=0; i<$scope.aircraftDetails.length;i++){ $scope.addData = []; $scope.addData.push({ 'tail': $scope.aircraftDetails[i].tail, 'make': $scope.aircraftDetails[i].make, 'model': $scope.aircraftDetails[i].model, 'sizeId' : $scope.aircraftDetails[i].sizeId, 'marginId': $scope.aircraftDetails[i].marginId }); |
b1f6160d4
|
149 |
} |
a4884cfe7
|
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
console.log($scope.addData) $scope.aircraftListData.aircraftList = $scope.addData; $scope.aircraftListData.accountId = companyId; CustomersService.addAircraft($scope.aircraftListData).then(function(result) { if(result != null && result.success){ toastr.success(''+result.success+'', { closeButton: true }) $('#aircraft-modal-3').modal('hide'); getAircraftList(); }else{ toastr.error(''+result.statusText+'', { closeButton: true }) |
b1f6160d4
|
165 |
} |
a4884cfe7
|
166 |
}); |
b1f6160d4
|
167 |
|
a4884cfe7
|
168 169 170 171 172 173 174 175 176 177 178 179 180 |
} $scope.showNoteData = true; $scope.showCompanyName = true; $scope.showAddress = true; $scope.showNote = function(){ $scope.showNoteData = false; $scope.showUpdateBtn = true; } $scope.company = function(){ $scope.showCompanyName = false; $scope.showUpdateBtn = true; } |
7152ff131
|
181 182 183 |
$scope.base = function(){ $scope.showUpdateBtn = true; } |
a4884cfe7
|
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
$scope.addressChange = function(){ $scope.showAddress = false; $scope.showUpdateBtn = true; } $scope.editData = function(inputName) { console.log($scope.companyData) $scope.showLoader = true; /*if(inputName == 'showNoteData'){ $scope.showNoteData = true; }else if(inputName == 'showCompanyName'){ $scope.showCompanyName = true; }else if(inputName == 'showAddress'){ $scope.showAddress = true; }*/ $scope.showNoteData = true; $scope.showCompanyName = true; $scope.showAddress = true; var companyData = "companyName=" + $scope.companyData.companyName + "&masterMargin=" + $scope.companyData.masterMargin + "&addressOne=" + $scope.companyData.addressOne + "&addressTwo=" + $scope.companyData.addressTwo + "&city=" + $scope.companyData.city + "&state=" + $scope.companyData.state + "&country=" + $scope.companyData.country + "&zipcode=" + $scope.companyData.zipcode + "&internalNote=" + $scope.companyData.internalNote + "&certificateType=" + $scope.companyData.certificateType + "&baseTenant=" + $scope.companyData.baseTenant + "&fuelerlinxCustomer=" + $scope.companyData.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.companyData.contractFuelVendor + "&activate=" + $scope.companyData.activate + "&baseIcao=" + $scope.companyData.baseIcao + "&companyId=" + companyId; ViewCompanyService.updateContact(companyData).then(function(result) { |
b1f6160d4
|
211 212 |
if(result != null && result.success){ toastr.success(''+result.success+'', { |
a4884cfe7
|
213 214 215 |
closeButton: true }) $scope.showUpdateBtn = false; |
b1f6160d4
|
216 217 |
}else{ toastr.error(''+result.statusText+'', { |
a4884cfe7
|
218 219 220 |
closeButton: true }) $scope.showUpdateBtn = true; |
b1f6160d4
|
221 |
} |
a4884cfe7
|
222 223 |
$scope.showLoader = false; }) |
b1f6160d4
|
224 |
|
a4884cfe7
|
225 |
} |
b1f6160d4
|
226 |
|
7152ff131
|
227 228 229 230 231 232 |
$scope.cancelData = function(){ $scope.showNoteData = true; $scope.showCompanyName = true; $scope.showAddress = true; $scope.showUpdateBtn = false; } |
a4884cfe7
|
233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
$scope.sendMail = function(){ ViewCompanyService.sendMail(companyId).then(function(result) { if(result != null && result.success){ toastr.success(''+result.success+'', { closeButton: true }) $('#confirm1').css('display', 'none'); }else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }) } |
b1f6160d4
|
247 |
|
a4884cfe7
|
248 249 250 |
$scope.openConfirmMail = function(){ $('#confirm1').css('display', 'block'); } |
48ed0c7bb
|
251 |
|
b1f6160d4
|
252 |
|
a4884cfe7
|
253 254 255 |
$scope.cancelAndCloseConfirm = function(){ $('#confirm1').css('display', 'none'); } |
3a9f4472b
|
256 |
|
a4884cfe7
|
257 258 259 260 |
$scope.cancelPrimaryContact = function(){ $('#primaryContact').css('display', 'none'); $scope.primaryContact = false; } |
3a9f4472b
|
261 |
|
a4884cfe7
|
262 263 264 265 266 267 268 269 |
$scope.checkPrimaryContact = function(){ if($scope.primaryContact == true){ ViewCompanyService.checkPrimaryContact(companyId).then(function(result) { console.log(result) if(result.status == 422){ $('#primaryContact').css('display', 'block'); } }) |
3a9f4472b
|
270 |
} |
a4884cfe7
|
271 |
} |
3a9f4472b
|
272 |
|
a4884cfe7
|
273 274 275 276 277 |
$scope.sendPrimaryContact = function(){ $scope.primaryContact = true; $('#primaryContact').css('display', 'none'); if($scope.primayData.id != null || $scope.primayData.id != undefined){ var priamryContactData = "companyContactId=" + $scope.primayData.id + "&primary=" + $scope.primaryContact; |
3a9f4472b
|
278 |
|
a4884cfe7
|
279 280 281 |
ViewCompanyService.addPrimaryContact(priamryContactData).then(function(result) { console.log(result) }) |
3a9f4472b
|
282 |
} |
a4884cfe7
|
283 284 |
} |
3a9f4472b
|
285 |
|
a4884cfe7
|
286 287 288 289 290 291 292 293 294 295 296 |
var newContactName = ""; $scope.updateData = "" $scope.showContact = function(data, value){ $('#updateContact').css('display', 'block'); $scope.updateData = data; newContactName = value; console.log($scope.updateData) if($scope.updateData.email == null){ $scope.updateData.content = data.contactNumber; }else{ $scope.updateData.content = data.email; |
3a9f4472b
|
297 |
} |
a4884cfe7
|
298 |
} |
3a9f4472b
|
299 |
|
a4884cfe7
|
300 301 302 303 304 305 306 307 308 309 |
$scope.acceptUpdateField = function(){ console.log($scope.updateData) if($scope.updateData.content == undefined){ toastr.error('Please add some content', { closeButton: true }) }else{ if(newContactName == 'phone'){ var updateCustomData = "companyId=" + companyId + "&contactNumber=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + "&title=" + $scope.updateData.title; |
e9a2edf03
|
310 |
}else{ |
a4884cfe7
|
311 312 |
var updateCustomData = "companyId=" + companyId + "&email=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + "&title=" + $scope.updateData.title; |
e9a2edf03
|
313 |
} |
a4884cfe7
|
314 315 316 317 318 |
ViewCompanyService.updateCustomField(updateCustomData).then(function(result) { console.log(result) if(result != null && result.success){ $('#updateContact').css('display', 'none'); getCompanyDetail(); |
e9a2edf03
|
319 |
} |
a4884cfe7
|
320 |
}) |
e9a2edf03
|
321 |
} |
a4884cfe7
|
322 |
} |
e9a2edf03
|
323 |
|
a4884cfe7
|
324 325 326 |
$scope.cancelUpdateField = function(){ $('#updateContact').css('display', 'none'); } |
e9a2edf03
|
327 |
|
a4884cfe7
|
328 329 330 331 |
$scope.showEditTier2 = function(number){ console.log(number) $scope.contactNumber = number; } |
8f88e39ed
|
332 |
|
e9a2edf03
|
333 |
|
a4884cfe7
|
334 335 336 337 338 339 |
var contactName = ''; $scope.addCustom = function(value){ console.log(value) if(value != null){ contactName = value; $('#customField').css('display', 'block'); |
3a9f4472b
|
340 |
} |
7152ff131
|
341 |
$scope.custom = {}; |
a4884cfe7
|
342 |
} |
8f88e39ed
|
343 |
|
a4884cfe7
|
344 345 346 |
$scope.cancelCustomField = function(){ $('#customField').css('display', 'none'); } |
7152ff131
|
347 |
|
a4884cfe7
|
348 349 350 351 352 353 354 355 356 |
$scope.acceptCustomField = function(){ if($scope.custom.content == undefined){ toastr.error('Please add some content', { closeButton: true }) }else{ if(contactName == 'phone'){ var customData = "companyId=" + companyId + "&contactNumber=" + $scope.custom.content + "&title=" + $scope.custom.title; |
3a9f4472b
|
357 |
}else{ |
a4884cfe7
|
358 359 |
var customData = "companyId=" + companyId + "&email=" + $scope.custom.content + "&title=" + $scope.custom.title; |
d24318592
|
360 |
} |
a4884cfe7
|
361 362 363 364 365 366 367 368 |
console.log(customData.email) ViewCompanyService.addCustomField(customData).then(function(result) { console.log(result) if(result != null && result.success){ $('#customField').css('display', 'none'); getCompanyDetail(); } }) |
3a9f4472b
|
369 |
} |
a4884cfe7
|
370 |
} |
28af27a3f
|
371 |
|
7152ff131
|
372 |
updateFuelManagerService.getFuelPricingNew().then(function(result) { |
28af27a3f
|
373 374 |
$scope.fuelPricing = result; for (var i = 0; i<$scope.fuelPricing.length; i++) { |
7152ff131
|
375 376 |
if ($scope.fuelPricing[i].fuelPricing.expirationDate != null) { $scope.fuelPricing[i].fuelPricing.expirationDate = new Date($scope.fuelPricing[i].fuelPricing.expirationDate) |
28af27a3f
|
377 378 379 |
} } }) |
a4884cfe7
|
380 |
|
55e075d7e
|
381 |
}]); |