Commit c7e2fd162298aa42ae2332a235371783f06f365c

Authored by Kuldeep Arora
1 parent c8eb439d97
Exists in master

testing

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