Blame view
app/partials/viewCompany/viewCompany.controller.js
44.7 KB
feacde5ff
|
1 |
'use strict'; |
5983d987a
|
2 3 |
//Load controller angular.module('acufuel') |
feacde5ff
|
4 |
|
9d840540f
|
5 |
.controller('viewCompanyController', ['$scope', '$uibModal', '$stateParams', 'ViewCompanyService', 'CustomersService', 'updateFuelManagerService', 'ViewFuelVendorService', 'ViewcontactService', '$state', 'fuelOrdersService', 'enterFuelOrderService', 'NgTableParams', function($scope, $uibModal, $stateParams, ViewCompanyService, CustomersService, updateFuelManagerService, ViewFuelVendorService, ViewcontactService, $state, fuelOrdersService, enterFuelOrderService, NgTableParams) { |
55e075d7e
|
6 7 |
$scope.data = {}; $scope.data.priceEmail = true; |
b1f6160d4
|
8 |
$scope.aircraft = {}; |
3a9f4472b
|
9 |
$scope.primayData = {}; |
d24318592
|
10 |
$scope.showLoader = false; |
ba1d39503
![]() |
11 |
$scope.showUpdateBtn = false; |
28af27a3f
|
12 |
$scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')); |
97f8c67f9
![]() |
13 |
$scope.selected = []; |
07328f442
![]() |
14 15 |
$scope.jetShow = []; $scope.marginShow = []; |
bfbbd8668
|
16 |
$scope.compId = $stateParams.id; |
07328f442
![]() |
17 18 |
$scope.jetShow[0] = true; $scope.marginShow[0] = true; |
5983d987a
|
19 |
$scope.dispatchOrder = {}; |
676250262
|
20 21 22 23 |
$scope.dispatchOrder.fuelOrderList = []; $scope.statusFilterOptions = []; $scope.companyList = {}; $scope.statusFilterOptions.push({ |
5983d987a
|
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
'id': '', 'title': 'Show All' }, { 'id': 'pending', 'title': 'Pending' }, { 'id': 'invoiced', 'title': 'Invoiced' }, { 'id': 'paid', 'title': 'Paid' }, { 'id': 'cancelled', 'title': 'Cancelled' }, { 'id': 'archived', 'title': 'Archived' |
676250262
|
41 |
} |
5983d987a
|
42 43 |
); |
9d840540f
|
44 45 46 |
$scope.order = {}; $scope.order.companyName = ''; $scope.order.upliftDate = ''; |
5983d987a
|
47 48 49 50 51 |
/*Get AllCompany api is used from CustomersService*/ getAllCompanies(); function getAllCompanies() { CustomersService.getAllCompanies().then(function(result) { |
40c8c308c
|
52 |
//console.log('log', result[2].id); |
5983d987a
|
53 |
$scope.companyList = result; |
40c8c308c
|
54 |
|
5983d987a
|
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 |
for (var i = 0; i < $scope.companyList.length; i++) { if ($scope.companyList[i].companyContact != null) { if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) { $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber; } } if ($scope.companyList[i].primaryContact != null) { if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) { $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName; } } if ($scope.companyList[i].margin != null) { if ($scope.companyList[i].margin.marginName != null) { $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; } } } $scope.displayCompanyList = new NgTableParams({ page: 1, count: 10, }, { data: $scope.companyList }); $scope.showLoader = false; }) } |
676250262
|
81 |
|
3a9f4472b
|
82 |
|
7152ff131
|
83 84 85 86 87 |
$(document).ready(function() { $("#reset").click(function() { $("input").val(""); }); }); |
5983d987a
|
88 89 90 91 92 93 94 95 96 97 98 99 |
$scope.values = [{ 'id': 1, 'first': 'Tenant/Base Customer' }, { 'id': 2, 'first': 'FuelerLinx Customer' }, { 'id': 3, 'first': 'CAA Member' } |
97f8c67f9
![]() |
100 |
]; |
bfbbd8668
|
101 |
|
5983d987a
|
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
$scope.changeValue = function(selected) { $scope.showUpdateBtn = true; // console.log("data to be true", selected); for (var i = 0; i < selected.length; i++) { // console.log(selected[i]) if (selected[i] == 'Tenant/Base Customer') { $scope.companyData.baseTenant = true; } else { $scope.companyData.baseTenant = false; } if (selected[i] == 'FuelerLinx Customer') { $scope.companyData.fuelerlinxCustomer = true; } else { $scope.companyData.fuelerlinxCustomer = false; } |
97f8c67f9
![]() |
117 |
|
5983d987a
|
118 119 120 121 122 123 124 |
if (selected[i] == 'CAA Member') { $scope.companyData.contractFuelVendor = true; } else { $scope.companyData.contractFuelVendor = false; } // console.log($scope.companyData) |
97f8c67f9
![]() |
125 |
|
5983d987a
|
126 |
} |
97f8c67f9
![]() |
127 128 129 130 131 132 133 134 |
} // $scope.selected =[ // {'id': 1, 'first': 'Tenant/Base Customer'}, // {'id': 2, 'first': 'FuelerLinx Customer'}, // {'id': 3, 'first': 'CAA Member'} // ]; |
d1fe89776
![]() |
135 136 137 |
// CustomersService.getMargin().then(function(result) { // $scope.marginList = result; // }) |
3a9f4472b
|
138 |
|
48ed0c7bb
|
139 |
var value = ""; |
55e075d7e
|
140 |
var companyId = $stateParams.id; |
bfbbd8668
|
141 |
|
a9a8f570d
|
142 143 144 |
$scope.companyData = {}; $scope.multipleMsg = false; $scope.companyData.masterMargin = ""; |
a9aef0b1c
|
145 |
$scope.isGlobal = false; |
0f34b8798
|
146 |
$scope.fboPreffered = false; |
e9a2edf03
|
147 |
getCompanyDetail(); |
5983d987a
|
148 149 150 151 152 153 |
function getCompanyDetail() { $scope.showLoader = true; ViewCompanyService.getCompany(companyId).then(function(result) { $scope.companyData = result; $scope.isGlobal = result.global; |
0f34b8798
|
154 |
$scope.fboPreffered = result.fboPreferred; |
5983d987a
|
155 156 157 158 159 160 161 162 163 |
if (result.global == true) { $scope.companyData.global = true; } if (result.margin != null) { $scope.companyData.masterMargin = result.margin.id; } if (result.marginAVGAS != null) { $scope.companyData.avgasMargin = result.marginAVGAS.id; } |
97f8c67f9
![]() |
164 |
|
97f8c67f9
![]() |
165 |
|
5983d987a
|
166 |
if ($scope.companyData.baseTenant) { |
97f8c67f9
![]() |
167 |
|
5983d987a
|
168 169 170 171 |
$scope.selected.push({ 'first': 'Tenant/Base Customer' }) // console.log("$scope.selected",$scope.selected) |
97f8c67f9
![]() |
172 |
|
5983d987a
|
173 |
} |
97f8c67f9
![]() |
174 |
|
5983d987a
|
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
if ($scope.companyData.fuelerlinxCustomer) { $scope.selected.push({ 'first': 'FuelerLinx Customer' }) // console.log("$scope.selected",$scope.selected) } if ($scope.companyData.contractFuelVendor) { $scope.selected.push({ 'first': 'CAA Member' }) // console.log("$scope.selected",$scope.selected) } // console.log("$scope.companyData",$scope.companyData) getAircraftList(); |
9d840540f
|
191 192 |
$scope.order.companyName = $scope.companyData.companyName; $scope.getAircraft(result.companyName); |
5983d987a
|
193 194 |
$scope.showLoader = false; }) |
e9a2edf03
|
195 |
} |
55e075d7e
|
196 |
|
5983d987a
|
197 198 |
$scope.changeCompanyStatus = function() { |
da24c95c8
![]() |
199 |
$('#delete3').css('display', 'block'); |
5983d987a
|
200 201 202 203 |
if ($scope.companyData.activate == true) { $scope.statusMessage = 'Please confirm! Are you sure you want to ACTIVATE this company?' } else { $scope.statusMessage = 'Please confirm! Are you sure you want to DEACTIVATE this company?' |
da24c95c8
![]() |
204 205 |
} } |
5983d987a
|
206 207 |
$scope.companyStatus = function() { $scope.showLoader = true; |
3a9f4472b
|
208 209 |
var statusData = "status=" + $scope.companyData.activate; ViewCompanyService.changeStatus(companyId, statusData).then(function(result) { |
5983d987a
|
210 211 212 213 214 215 216 |
if (result.success) { $('#delete3').css('display', 'none'); toastr.success('' + result.success + '', { closeButton: true }) getContactList(); } |
3a9f4472b
|
217 |
}) |
05bfa28a2
|
218 |
$scope.showLoader = false; |
c555af312
|
219 |
} |
3a9f4472b
|
220 |
|
5983d987a
|
221 222 |
$scope.cancelStatus = function() { |
da24c95c8
![]() |
223 |
$('#delete3').css('display', 'none'); |
5983d987a
|
224 |
$scope.companyData.activate = !$scope.companyData.activate; |
da24c95c8
![]() |
225 |
} |
5983d987a
|
226 |
|
48ed0c7bb
|
227 |
getContactList(); |
5983d987a
|
228 229 230 231 232 |
function getContactList() { ViewCompanyService.getContact(companyId).then(function(result) { $scope.companyContactList = result; }) |
48ed0c7bb
|
233 |
} |
a9a8f570d
|
234 |
$scope.aircraftmargins = []; |
5983d987a
|
235 |
|
bcd6c1025
|
236 237 |
$scope.abc = false; $scope.xyz = false; |
5983d987a
|
238 239 |
function getAircraftList() { ViewCompanyService.getAircraft(companyId).then(function(result) { |
bcd6c1025
|
240 |
|
5983d987a
|
241 242 243 244 245 246 |
$scope.contactAircraftList = result; for (var i = 0; i < $scope.contactAircraftList.length; i++) { if ($scope.contactAircraftList[i].aircraftsMargin != null) { $scope.aircraftmargins.push({ 'id': $scope.contactAircraftList[i].aircraftsMargin.id }) |
cca8fa318
|
247 248 |
$scope.contactAircraftList[i].fuelType = "Jet-A"; $scope.contactAircraftList[i].marginValue = result[i].aircraftsMargin.marginValue; |
dadb46117
|
249 |
$scope.abc = true; |
bcd6c1025
|
250 251 252 |
}else{ $scope.contactAircraftList[i].fuelType = "100LL"; |
a858eca3e
|
253 |
if (result[i].aircraftsAVGASMargin != null) { |
cca8fa318
|
254 |
$scope.contactAircraftList[i].marginValue = result[i].aircraftsAVGASMargin.marginValue; |
dadb46117
|
255 |
$scope.xyz = true; |
a858eca3e
|
256 257 |
} |
5983d987a
|
258 |
} |
bcd6c1025
|
259 |
|
5983d987a
|
260 261 262 263 264 265 266 267 268 |
} if ($scope.aircraftmargins.length > 0) { for (var i = 0; i < $scope.aircraftmargins.length; i++) { if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) { $scope.multiple = true; $scope.multipleMsg = true; if ($scope.multiple) { $scope.companyData.masterMargin = "multiple"; } |
a9a8f570d
|
269 |
} |
5983d987a
|
270 |
} |
a9a8f570d
|
271 |
} |
5983d987a
|
272 |
}) |
b1f6160d4
|
273 |
} |
b1f6160d4
|
274 |
|
5983d987a
|
275 |
|
55e075d7e
|
276 277 |
$scope.contactData = {}; $scope.contactData.contactList = []; |
5983d987a
|
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
$scope.addContact = function() { $scope.showLoader = true; $scope.data.companyId = companyId; $scope.contactData.contactList.push($scope.data); ViewCompanyService.addContact($scope.contactData).then(function(result) { //console.log("data==",$scope.contactData) // console.log(result) if (result.status == 200) { $('#contact-modal-3').modal('hide'); $scope.primayData.id = result.data; $scope.data = {}; $scope.sendPrimaryContact(); getContactList(); $scope.contactData.contactList = []; $scope.data.email = ''; |
5983d987a
|
294 |
toastr.success('Created Successfully', { |
cf43d578a
|
295 |
closeButton: true |
5983d987a
|
296 297 298 299 300 301 302 303 |
}) } else { toastr.error('' + result.statusText + '', { closeButton: true }) } }) $scope.showLoader = false; |
55e075d7e
|
304 |
} |
feacde5ff
|
305 |
|
5983d987a
|
306 307 308 309 310 311 |
getData(); function getData() { $scope.showLoader = true; CustomersService.getAircraftMake().then(function(result) { $scope.aircraftMakeList = result; |
40c8c308c
|
312 |
// console.log("make",result) |
5983d987a
|
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
}) $scope.showLoader = false; } $scope.clearAircrafts = function() { $scope.aircraftDetails = []; $scope.aircraftDetails = [{ 'tail': '', 'make': '', 'model': '', 'sizeId': '', 'marginId': '', 'avgasMarginId': '' }]; } $scope.addNew = function() { $scope.aircraftDetails.push({ 'tail': '', 'make': '', 'model': '', 'sizeId': '', 'marginId': '', 'avgasMarginId': '' |
a4884cfe7
|
337 |
}); |
5983d987a
|
338 339 340 341 342 343 |
// console.log($scope.aircraftDetails) }; $scope.getModal = function(makeId, index) { $scope.showLoader = true; $scope.aircraft.make = makeId; |
5983d987a
|
344 |
CustomersService.getModal($scope.aircraft.make).then(function(result) { |
33a64416f
|
345 346 347 348 |
$scope.showLoader = false; $scope.aircraftDetails[index].aircraftModalList = result; //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; }) |
b1f6160d4
|
349 |
} |
33a64416f
|
350 |
|
bfbbd8668
|
351 |
$scope.selectedOption = ''; |
5983d987a
|
352 353 |
$scope.getSize = function(model, index) { $scope.showLoader = true; |
33a64416f
|
354 |
$scope.aircraft.model = model; |
5983d987a
|
355 356 357 |
CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { $scope.showLoader = false; $scope.aircraftDetails[index].aircraftSizeList = result; |
0a364e561
|
358 |
$scope.getFuelType($scope.aircraftDetails[index].aircraftSizeList[0].aircraftSize.id,index); |
88abaa681
|
359 |
|
6367e69ba
|
360 |
|
5983d987a
|
361 362 |
}) } |
33a64416f
|
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
$scope.getFuelType = function(size, index) { $scope.showLoader = true; var data = "model="+$scope.aircraft.model+"&make="+$scope.aircraft.make+"&sizeId="+size; ViewCompanyService.checkFuelType(data).then(function(result){ $scope.showLoader = false; if (result.type == "JetA") { $scope.jetShow[index] = false; $scope.marginShow[index] = true; } else if (result.type == "Avgas") { $scope.jetShow[index] = true; $scope.marginShow[index] = false; }else { $scope.jetShow[index] = true; $scope.marginShow[index] = true; } }) } |
5983d987a
|
381 382 |
$scope.aircraftListData = {}; |
359303f53
|
383 384 385 386 387 |
$scope.addData = []; $scope.tailArray = []; function check(array){ return (new Set(array)).size !== array.length; } |
5983d987a
|
388 |
$scope.saveCompanyData = function() { |
359303f53
|
389 |
$scope.tailArray = []; |
2075411ed
|
390 |
for (var i = 0; i < $scope.aircraftDetails.length; i++) { |
2075411ed
|
391 392 393 394 395 396 397 398 |
$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, 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId }); |
359303f53
|
399 400 |
$scope.tailArray.push($scope.aircraftDetails[i].tail); } |
359303f53
|
401 402 403 404 405 406 |
if (check($scope.tailArray)) { toastr.error('Duplicate Tail Added.', { closeButton: true }) }else{ $scope.aircraftListData.aircraftList = $scope.addData; |
e443a586b
|
407 |
$scope.aircraftListData.accountId = companyId; |
359303f53
|
408 409 410 411 412 |
CustomersService.addAircraft($scope.aircraftListData).then(function(result) { if (result != null && result.success) { toastr.success('' + result.success + '', { closeButton: true }) |
6367e69ba
|
413 414 415 |
$scope.addData= []; $scope.tailArray = []; $scope.aircraftListData={}; |
359303f53
|
416 417 |
$('#aircraft-modal-3').css('display', 'none'); $('.modal-backdrop').css('display', 'none'); |
8f525d21f
|
418 419 |
$('#aircraft-modal-3').modal('hide'); $('.modal-backdrop').modal('hide'); |
359303f53
|
420 |
getAircraftList(); |
8f525d21f
|
421 |
|
359303f53
|
422 |
} else { |
8f525d21f
|
423 424 |
$('#aircraft-modal-3').css('display', 'none'); $('.modal-backdrop').css('display', 'none'); |
359303f53
|
425 426 427 428 429 |
toastr.error('' + result.statusText + '', { closeButton: true }) } }); |
5983d987a
|
430 |
} |
2075411ed
|
431 |
|
5983d987a
|
432 |
} |
2075411ed
|
433 |
|
5983d987a
|
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
$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; } $scope.base = function() { $scope.showUpdateBtn = true; } $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; }*/ |
a4884cfe7
|
466 |
$scope.showNoteData = true; |
a4884cfe7
|
467 |
$scope.showCompanyName = true; |
5983d987a
|
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
$scope.showAddress = true; var companyData = "companyName=" + $scope.companyData.companyName + "&masterMargin=" + $scope.companyData.masterMargin + "&avgasMargin=" + $scope.companyData.avgasMargin + "&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 + "&global=" + $scope.companyData.global; ViewCompanyService.updateCompany(companyData).then(function(result) { if (result != null && result.success) { toastr.success('' + result.success + '', { closeButton: true }) $scope.showUpdateBtn = false; getCompanyDetail(); } else { |
9d840540f
|
485 |
toastr.error('Error Updating Company', { |
5983d987a
|
486 487 488 489 490 491 492 |
closeButton: true }) $scope.showUpdateBtn = true; } $scope.showLoader = false; }) } |
9d840540f
|
493 |
$scope.cancelUpdateData = function() { |
5983d987a
|
494 495 496 497 498 499 500 |
$scope.showNoteData = true; $scope.showCompanyName = true; $scope.showAddress = true; $scope.showUpdateBtn = false; } $scope.sendMail = function() { |
9d840540f
|
501 |
$scope.showLoader = true; |
5983d987a
|
502 503 504 505 506 507 508 |
$('#confirm1').css('display', 'none'); ViewCompanyService.sendMail(companyId).then(function(result) { if (result != null && result.success) { toastr.success('' + result.success + '', { closeButton: true }) } else { |
9d840540f
|
509 |
toastr.error('Error Sending Email', { |
5983d987a
|
510 511 512 |
closeButton: true }) } |
9d840540f
|
513 |
$scope.showLoader = false; |
5983d987a
|
514 515 516 517 518 519 |
}) } $scope.openConfirmMail = function() { $('#confirm1').css('display', 'block'); } |
b1f6160d4
|
520 |
|
48ed0c7bb
|
521 |
|
5983d987a
|
522 523 524 |
$scope.cancelAndCloseConfirm = function() { $('#confirm1').css('display', 'none'); } |
b1f6160d4
|
525 |
|
a4884cfe7
|
526 |
$scope.primaryContact = false; |
5983d987a
|
527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
$scope.cancelPrimaryContact = function() { $('#primaryContact').css('display', 'none'); $scope.primaryContact = false; } $scope.checkPrimaryContact = function() { if ($scope.primaryContact == true) { $scope.primaryContact = true; ViewCompanyService.checkPrimaryContact(companyId).then(function(result) { //console.log(result) if (result.status == 422) { $('#primaryContact').css('display', 'block'); } }) |
a4884cfe7
|
541 |
} |
5983d987a
|
542 543 544 545 546 547 548 549 550 551 |
} $scope.sendPrimaryContact = function() { $('#primaryContact').css('display', 'none'); if ($scope.primayData.id != null || $scope.primayData.id != undefined) { var priamryContactData = "companyContactId=" + $scope.primayData.id + "&primary=" + $scope.primaryContact; ViewCompanyService.addPrimaryContact(priamryContactData).then(function(result) { // console.log(result) }) |
8670c5905
|
552 |
} |
8670c5905
|
553 |
} |
5983d987a
|
554 |
$scope.updateData = "" |
9d840540f
|
555 |
$scope.showUpdateContact = function(data, value) { |
5983d987a
|
556 557 |
$('#updateContact').css('display', 'block'); $scope.updateData = data; |
9d840540f
|
558 559 560 561 562 563 564 565 566 567 568 |
// console.log($scope.updateData) if ($scope.updateData.email == null) { $scope.updateData.content = data.contactNumber; } else { $scope.updateData.content = data.email; } } $scope.showUpdateEmail = function(data, value) { $('#updateEmail').css('display', 'block'); $scope.updateData = data; |
5983d987a
|
569 570 571 572 573 574 575 |
// console.log($scope.updateData) if ($scope.updateData.email == null) { $scope.updateData.content = data.contactNumber; } else { $scope.updateData.content = data.email; } } |
9d840540f
|
576 |
$scope.acceptUpdateField = function(newContactName) { |
5983d987a
|
577 578 579 |
// console.log($scope.updateData) if ($scope.updateData.content == undefined) { toastr.error('Please add some content', { |
cdf775224
|
580 581 |
closeButton: true }) |
5983d987a
|
582 583 584 585 586 587 588 589 590 |
} else { if (newContactName == 'phone') { var updateCustomData = "companyId=" + companyId + "&contactNumber=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + "&title=" + $scope.updateData.title; } else { var updateCustomData = "companyId=" + companyId + "&email=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + "&title=" + $scope.updateData.title; } ViewCompanyService.updateCustomField(updateCustomData).then(function(result) { |
5983d987a
|
591 592 |
if (result != null && result.success) { $('#updateContact').css('display', 'none'); |
9d840540f
|
593 |
$('#updateEmail').css('display', 'none'); |
5983d987a
|
594 595 596 |
getCompanyDetail(); } }) |
cdf775224
|
597 |
} |
cdf775224
|
598 |
} |
9d840540f
|
599 600 601 602 603 604 605 606 607 608 609 |
$scope.deleteContent = function(data){ ViewCompanyService.deleteCustomContact(data.id).then(function(result) { if (result != null && result.success) { toastr.success('' + result.success + '', { closeButton: true }) getCompanyDetail(); } }) } |
07328f442
![]() |
610 |
|
5983d987a
|
611 612 |
$scope.cancelUpdateField = function() { $('#updateContact').css('display', 'none'); |
9d840540f
|
613 |
$('#updateEmail').css('display', 'none'); |
5983d987a
|
614 615 616 617 618 619 |
} $scope.showEditTier2 = function(number) { // console.log(number) $scope.contactNumber = number; } |
07328f442
![]() |
620 |
|
5983d987a
|
621 |
|
9d840540f
|
622 |
$scope.addCustomPhone = function(value) { |
5983d987a
|
623 624 |
//console.log(value) if (value != null) { |
9d840540f
|
625 626 627 628 629 630 631 632 633 |
$('#customFieldPhone').css('display', 'block'); } $scope.custom = {}; } $scope.addCustomEmail = function(value) { //console.log(value) if (value != null) { $('#customFieldEmail').css('display', 'block'); |
07328f442
![]() |
634 |
} |
5983d987a
|
635 |
$scope.custom = {}; |
07328f442
![]() |
636 |
} |
cf43d578a
|
637 |
|
5983d987a
|
638 |
$scope.cancelCustomField = function() { |
9d840540f
|
639 640 |
$('#customFieldEmail').css('display', 'none'); $('#customFieldPhone').css('display', 'none'); |
5983d987a
|
641 |
} |
676250262
|
642 |
|
9d840540f
|
643 |
$scope.acceptCustomField = function(contactName) { |
5983d987a
|
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 |
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; } else { var customData = "companyId=" + companyId + "&email=" + $scope.custom.content + "&title=" + $scope.custom.title; } // console.log(customData.email) ViewCompanyService.addCustomField(customData).then(function(result) { // console.log(result) if (result != null && result.success) { |
9d840540f
|
660 661 662 |
$('#customFieldEmail').css('display', 'none'); $('#customFieldPhone').css('display', 'none'); $scope.custom = {}; |
5983d987a
|
663 664 665 666 667 |
getCompanyDetail(); } }) } } |
676250262
|
668 |
|
64b3dc0e3
|
669 |
/* omit strike out*/ |
5983d987a
|
670 671 |
updateFuelManagerService.getFuelPricingNew().then(function(result) { $scope.fuelPricing = result; |
169fc146e
|
672 |
//console.log("==fuel pricing==",result) |
bfbbd8668
|
673 674 675 |
$scope.omitData; ViewCompanyService.getOmitCompany($scope.compId).then(function(result){ $scope.omitData = result; |
169fc146e
|
676 |
// console.log("omit data===", $scope.omitData); |
64b3dc0e3
|
677 678 679 680 |
for(var i = 0 ; i< $scope.fuelPricing.length; i++){ for(var j = 0; j<$scope.omitData.length; j++){ if($scope.omitData[j].marginId == $scope.fuelPricing[i].fuelPricing.id){ $scope.fuelPricing[i].fuelPricing.omit = $scope.omitData[j].omit; |
169fc146e
|
681 |
// console.log("fuel.pricing.omit",$scope.fuelPricing[i].fuelPricing.omit) |
64b3dc0e3
|
682 683 684 |
} } } |
bfbbd8668
|
685 |
}) |
64b3dc0e3
|
686 |
// console.log("$scope.fuelPricing",$scope.fuelPricing) |
5983d987a
|
687 |
for (var i = 0; i < $scope.fuelPricing.length; i++) { |
64b3dc0e3
|
688 |
// console.log('$scope.fuelPricing[i].fuelPricing', $scope.fuelPricing[i].fuelPricing); |
dadb46117
|
689 |
//console.log("fuelid",$scope.fuelPricing[i].fuelPricing.id,"getid",$scope.omitData[j].id) |
5983d987a
|
690 691 692 693 694 695 696 697 |
if ($scope.fuelPricing[i].fuelPricing.expirationDate != null) { $scope.fuelPricing[i].fuelPricing.expirationDate = new Date($scope.fuelPricing[i].fuelPricing.expirationDate); var newTime = new Date($scope.fuelPricing[i].fuelPricing.expirationDate); var dmonth = newTime.getUTCMonth() + 1; //months from 1-12 var dday = newTime.getUTCDate(); var dyear = newTime.getUTCFullYear(); $scope.fuelPricing[i].fuelPricing.expirationDate = dmonth + '/' + dday + '/' + dyear; } |
bfbbd8668
|
698 699 700 701 702 |
// for (var j = 0; j<$scope.omitData.length; j++) { // if($scope.fuelPricing[i].fuelPricing.id === $scope.omitData[j].id){ // } // } |
5983d987a
|
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 |
} }) var deleteAircraftId = ""; $scope.deleteAircraft = function(id) { $('#delete1').css('display', 'block'); deleteAircraftId = id; } $scope.aircraftDelete = function() { ViewCompanyService.deleteAircraft(deleteAircraftId).then(function(result) { // console.log(result) getAircraftList(); getCompanyDetail(); $('#delete1').css('display', 'none'); }) } |
de63dd418
|
720 |
$scope.cancelAircraft = function() { |
5983d987a
|
721 722 723 724 725 726 727 728 729 730 |
$('#delete1').css('display', 'none'); } CustomersService.getJetMargin($scope.userProfileId).then(function(result) { $scope.jetMarginList = result; }) CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { $scope.avgsMarginList = result; }) |
676250262
|
731 |
|
5983d987a
|
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
$scope.changePriceEmail = function(id, index) { event.stopPropagation(); var contactId = id; var statusData = "status=" + $scope.companyContactList[index].priceEmail; ViewcontactService.changePriceEmail(contactId, statusData).then(function(result) { if (result.success) { $('#toogleMail').css('display', 'block'); if ($scope.companyContactList[index].priceEmail == true) { $scope.messageText = 'You have enabled price distribution for this contact'; } else { $scope.messageText = 'You have disabled price distribution for this contact'; } } }) } $scope.cancelToogle = function() { $('#toogleMail').css('display', 'none'); } $scope.checkboxStatus = function(value) { // console.log("checkbox",value) $scope.showUpdateBtn = true; } $scope.fuelercheckboxStatus = function(value) { $('#fuelerchange').css('display', 'block'); if (value == true) { $scope.statusMessage = 'Please confirm! Enabling FuelerLinx for this customer will enable price distribution web services and disable price emails for the contacts in this company' } else { $scope.statusMessage = 'Please confirm! Disabling FuelerLinx for this customer will disable price distribution web services into their FuelerLinx account. If you proceed then remember to enable price emails for the appropriate contacts in this company.' |
676250262
|
763 |
} |
676250262
|
764 |
|
5983d987a
|
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 |
} $scope.fuelerCancelStatus = function() { $('#fuelerchange').css('display', 'none'); $scope.companyData.fuelerlinxCustomer = !$scope.companyData.fuelerlinxCustomer; } $scope.fuelerAcceptStatus = function() { $('#fuelerchange').css('display', 'none'); $scope.showLoader = true; var statusData; if ($scope.companyData.fuelerlinxCustomer == false) { statusData = "status=true"; } else { statusData = "status=false"; } ViewCompanyService.fuelerPricingChange(companyId, statusData).then(function(result) { if (result.success) { $scope.showLoader = false; $scope.editData(); getContactList(); } |
676250262
|
790 |
}) |
5983d987a
|
791 |
} |
bcd6c1025
|
792 |
|
5983d987a
|
793 794 795 |
$scope.updateOmit = function(fuel, omit) { $scope.fuelData = {}; $scope.fuelData.expirationDate = new Date(fuel.expirationDate); |
bfbbd8668
|
796 |
$scope.fuelData.customMarginId = fuel.id; |
5983d987a
|
797 798 799 800 |
$scope.fuelData.omit = fuel.omit; $scope.fuelData.papMargin = fuel.papMargin; $scope.fuelData.papTotal = fuel.papTotal; $scope.fuelData.cost = fuel.cost; |
bfbbd8668
|
801 |
$scope.fuelData.companyId = $scope.compId ; |
bfbbd8668
|
802 803 |
if($scope.fuelData.omit == true) { |
bfbbd8668
|
804 |
var customData = "companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId; |
20b4aefe7
|
805 |
// console.log(".") |
bfbbd8668
|
806 807 808 809 810 811 812 813 814 815 816 817 |
ViewCompanyService.omitAddCompanyFuel(customData).then(function(result) { if (result.success) { toastr.success('' + result.success + '', { closeButton: true }) } else { toastr.error('' + result.statusText + '', { closeButton: true }) } }) }else{ |
64b3dc0e3
|
818 819 |
var data ="companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId; ViewCompanyService.omitDeleteCompanyFuel(data).then(function(result){ |
bfbbd8668
|
820 821 822 823 824 825 826 827 828 829 830 |
if (result.success) { toastr.success('' + result.success + '', { closeButton: true }) } else { toastr.error('' + result.statusText + '', { closeButton: true }) } }) } |
5983d987a
|
831 |
} |
bfbbd8668
|
832 |
|
bcd6c1025
|
833 |
//--fuel type based on tail is not in use-- |
5983d987a
|
834 |
// $scope.aircraftData = {} |
1d6e37847
|
835 |
/*$scope.checkJetWithTail = function(tail, index) { |
5983d987a
|
836 |
|
1d6e37847
|
837 |
console.log("tail==============",tail, index) |
5983d987a
|
838 |
ViewCompanyService.checkJetType(tail).then(function(result) { |
1d6e37847
|
839 |
console.log("result",result) |
5983d987a
|
840 841 842 843 844 845 846 |
if (result.jetA == "true") { $scope.jetShow[index] = false; $scope.marginShow[index] = true; } else { $scope.jetShow[index] = true; $scope.marginShow[index] = false; } |
676250262
|
847 |
}) |
1d6e37847
|
848 |
}*/ |
5983d987a
|
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 |
/*add a fuel order*/ $scope.getOrders = function() { fuelOrdersService.getOrders().then(function(result) { $scope.orderdata = result; for (var i = 0; i < $scope.orderdata.length; i++) { $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear() var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear() // str = str.slice(4,16) $scope.orderdata[i].upliftDateString = str // console.log(str); } $scope.displayFuelOrderList = new NgTableParams({ page: 1, count: 10, }, { data: $scope.orderdata }); $(document).ready(function() { var myselect = document.getElementsByClassName('colorfulSelectbox'); for (var i = 0; i < myselect.length; i++) { var colourIndex = $(myselect[i]).prop('selectedIndex'); colourIndex = colourIndex + 1; // console.log(colourIndex); var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color'); $(myselect[i]).css('background-color', getColor); // console.log('colour', getColor); myselect[i].blur(); } |
676250262
|
886 |
}) |
5983d987a
|
887 |
|
676250262
|
888 |
}) |
5983d987a
|
889 890 891 |
} $scope.getOrders(); |
9d840540f
|
892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
$scope.tiervalue=function(){ $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; } $scope.setCost = function(cost){ if(cost != null) { var obj =JSON.parse(cost); $scope.order.fboCost = obj.cost; } } $scope.cancelOrder = function() { $scope.order = {}; } $scope.dispatchFuel = function(){ $scope.showLoader = true; $scope.order.companyId = $scope.compId; if ($scope.order.upliftDate != '') { var currentDate = new Date(); var hours = currentDate.getHours(); var min = currentDate.getMinutes(); var sec = currentDate.getSeconds(); $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; $scope.order.upliftDate = new Date($scope.order.upliftDate); $scope.order.upliftDate = $scope.order.upliftDate.getTime(); } $scope.order.status = 'pending'; var obj =JSON.parse($scope.order.priceQuote); |
748fc1d4b
|
922 923 924 |
$scope.order.priceQuote = obj.papTotal; $scope.order.fboCost = obj.cost; $scope.order.total = obj.papTotal * $scope.order.volume; |
9d840540f
|
925 926 927 928 929 930 931 932 933 934 935 |
var aircraftObj =JSON.parse($scope.order.aircraftName); $scope.order.aircraftName = aircraftObj.tail; $scope.order.make = aircraftObj.make; $scope.order.model = aircraftObj.model; $scope.dispatchOrder.fuelOrderList.push($scope.order); enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { $scope.showLoader = false; $scope.order = {}; $('#demo-modal-4').css('display', ''); toastr.success('Fuel Order Dispatched Successfully', { closeButton: true |
5983d987a
|
936 |
}) |
9d840540f
|
937 938 |
}) } |
5983d987a
|
939 940 941 942 943 944 945 946 947 948 |
$scope.addTotal = function(value, valueOf) { if (valueOf == 'v') { $scope.order.total = value * $scope.order.invoiced } else if (valueOf == 'i') { $scope.order.total = $scope.order.volume * value } } $scope.getAircraft = function(company) { |
5983d987a
|
949 |
$scope.selectedCompanyName = company; |
9d840540f
|
950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 |
if ($scope.companyData.margin != null && $scope.companyData.marginAVGAS != null) { fuelOrdersService.getFuelCost($scope.companyData.id).then(function(margins) { $scope.marginList = margins; //console.log('$scope.marginList', $scope.marginList); }) } else if ($scope.companyData.margin != null || $scope.companyData.marginAVGAS == null) { fuelOrdersService.getATypeFuelPricing($scope.companyData.id).then(function(margins) { $scope.marginList = margins; }) } else if ($scope.companyData.margin == null || $scope.companyData.marginAVGAS != null) { fuelOrdersService.getVTypeFuelPricing($scope.companyData.id).then(function(margins) { $scope.marginList = margins; }) } $scope.selectedCompanyId = $scope.companyData.id; $scope.marginId = $scope.companyData.margin.id; if ($scope.selectedCompanyId != '') { fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { $scope.aircraftList = aircraft; }) } if ($scope.marginId != '') { fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) { $scope.tierList = tiers; // $scope.showLoader = false; }) |
5983d987a
|
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
} } $scope.setCost = function(cost) { // console.log(cost); if (cost != null) { var obj = JSON.parse(cost); // console.log("0bj",obj) $scope.order.fboCost = obj.cost; } } $scope.sourceList = [{ source: "Direct Jet-A" }, { source: "Direct AVGAS 100LL" }]; $scope.cancelData = function() { |
676250262
|
999 |
$('#demo-modal-4').css('display', ''); |
5983d987a
|
1000 1001 1002 1003 |
} $scope.setFuel = function() { $('#demo-modal-4').css('display', 'block'); |
676250262
|
1004 |
|
5983d987a
|
1005 |
} |
676250262
|
1006 |
|
cf43d578a
|
1007 |
/*delete company*/ |
5983d987a
|
1008 1009 |
var deletecompanyId = ""; $scope.deleteComp = function(companyDataid) { |
cf43d578a
|
1010 1011 1012 1013 |
$('#delete2').css('display', 'block'); //console.log("asda",companyDataid) deletecompanyId = companyDataid; } |
1d7e82fdd
|
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 |
$scope.aircraftIdx = ''; $scope.checkTail = function(tail, idx){ var data = "tail=" + tail + "&id=" + companyId; $scope.aircraftIdx = idx; ViewCompanyService.checkTail(data).then(function(result) { if(result.error) { $scope.aircraftMessage = result.error; $scope.openAddAirCraftError(); } else if(result.warning) { $scope.aircraftMessage = result.warning; $scope.openAddAirCraftWarning(); } }) } |
cf43d578a
|
1028 |
|
1d7e82fdd
|
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
$scope.openAddAirCraftError = function() { $('#addAirCraftError').css('display', 'block'); } $scope.openAddAirCraftWarning = function() { $('#addAirCraftWarning').css('display', 'block'); } $scope.acceptAirCraftError = function() { $('#addAirCraftWarning').css('display', 'none'); } $scope.cancelAirCraftError = function() { $scope.aircraftDetails[$scope.aircraftIdx].tail = ''; $('#addAirCraftWarning').css('display', 'none'); $('#addAirCraftError').css('display', 'none'); } |
5983d987a
|
1046 |
$scope.deleteCompanyData = function() { |
cf43d578a
|
1047 |
ViewCompanyService.deleteCompany(deletecompanyId).then(function(result) { |
cf43d578a
|
1048 |
|
5983d987a
|
1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 |
$('#delete2').css('display', 'none'); if (result.success) { toastr.success('' + result.success + '', { closeButton: true }) } else { toastr.error('' + result.statusText + '', { closeButton: true }) } $state.go('app.customers') }) } $scope.cancelDelete = function() { $('#delete2').css('display', 'none'); } |
cf43d578a
|
1067 |
|
5983d987a
|
1068 1069 |
$scope.editJetMargin = function(aircraftData, type) { $scope.showLoader = true; |
6c5a99488
|
1070 |
if (type == 'jet') { |
cca8fa318
|
1071 |
|
5983d987a
|
1072 |
var aircraftdataMargin = "marginId=" + aircraftData.aircraftsMargin.id + "&type=" + type; |
cca8fa318
|
1073 |
|
5983d987a
|
1074 |
} else { |
5983d987a
|
1075 |
var aircraftdataMargin = "marginId=" + aircraftData.aircraftsAVGASMargin.id + "&type=" + type; |
cf43d578a
|
1076 |
} |
5983d987a
|
1077 1078 1079 1080 1081 1082 1083 1084 |
var id = aircraftData.id; ViewCompanyService.updateAircraftMargin(aircraftdataMargin, id).then(function(result) { if (result != null && result.success) { $scope.showLoader = false; toastr.success('' + result.success + '', { closeButton: true }) |
bcd6c1025
|
1085 1086 |
// getAircraftWithMarginList(); getAircraftList(); |
5983d987a
|
1087 1088 1089 1090 1091 1092 1093 1094 |
} else { $scope.showLoader = false; toastr.error('' + result.statusText + '', { closeButton: true }) } }) } |
cca8fa318
|
1095 1096 |
/* //not used currently |
5983d987a
|
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 |
function getAircraftWithMarginList() { ViewCompanyService.getJetAMargin(companyId).then(function(result) { $scope.contactAircraftList = result; for (var i = 0; i < $scope.contactAircraftList.length; i++) { if ($scope.contactAircraftList[i].aircraftsMargin != null) { $scope.aircraftmargins.push({ 'id': $scope.contactAircraftList[i].aircraftsMargin.id }) } } if ($scope.aircraftmargins.length > 0) { for (var i = 0; i < $scope.aircraftmargins.length; i++) { if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) { $scope.multiple = true; $scope.multipleMsg = true; if ($scope.multiple) { $scope.companyData.masterMargin = "multiple"; } } } } |
cf43d578a
|
1118 |
}) |
cca8fa318
|
1119 |
}*/ |
40c8c308c
|
1120 |
|
40c8c308c
|
1121 |
|
5983d987a
|
1122 |
}]); |