Commit 6367e69ba97da22579f49703a7d71c1f696d7fab

Authored by Kuldeep Arora
1 parent e443a586b3
Exists in master

minor

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 $scope.contactAircraftList[i].marginValue = result[i].aircraftsAVGASMargin.marginValue; 261 $scope.contactAircraftList[i].marginValue = result[i].aircraftsAVGASMargin.marginValue;
262 $scope.xyz = true; 262 $scope.xyz = true;
263 } 263 }
264 264
265 } 265 }
266 if ($scope.aircraftmargins.length > 0) { 266 if ($scope.aircraftmargins.length > 0) {
267 for (var i = 0; i < $scope.aircraftmargins.length; i++) { 267 for (var i = 0; i < $scope.aircraftmargins.length; i++) {
268 if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) { 268 if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) {
269 $scope.multiple = true; 269 $scope.multiple = true;
270 $scope.multipleMsg = true; 270 $scope.multipleMsg = true;
271 if ($scope.multiple) { 271 if ($scope.multiple) {
272 $scope.companyData.masterMargin = "multiple"; 272 $scope.companyData.masterMargin = "multiple";
273 } 273 }
274 } 274 }
275 } 275 }
276 } 276 }
277 }) 277 })
278 } 278 }
279 279
280 280
281 281
282 $scope.contactData = {}; 282 $scope.contactData = {};
283 $scope.contactData.contactList = []; 283 $scope.contactData.contactList = [];
284 $scope.addContact = function() { 284 $scope.addContact = function() {
285 $scope.showLoader = true; 285 $scope.showLoader = true;
286 $scope.data.companyId = companyId; 286 $scope.data.companyId = companyId;
287 $scope.contactData.contactList.push($scope.data); 287 $scope.contactData.contactList.push($scope.data);
288 ViewCompanyService.addContact($scope.contactData).then(function(result) { 288 ViewCompanyService.addContact($scope.contactData).then(function(result) {
289 //console.log("data==",$scope.contactData) 289 //console.log("data==",$scope.contactData)
290 // console.log(result) 290 // console.log(result)
291 if (result.status == 200) { 291 if (result.status == 200) {
292 292
293 $('#contact-modal-3').modal('hide'); 293 $('#contact-modal-3').modal('hide');
294 $scope.primayData.id = result.data; 294 $scope.primayData.id = result.data;
295 $scope.data = {}; 295 $scope.data = {};
296 $scope.sendPrimaryContact(); 296 $scope.sendPrimaryContact();
297 getContactList(); 297 getContactList();
298 $scope.contactData.contactList = []; 298 $scope.contactData.contactList = [];
299 $scope.data.email = ''; 299 $scope.data.email = '';
300 toastr.success('Created Successfully', { 300 toastr.success('Created Successfully', {
301 closeButton: true 301 closeButton: true
302 }) 302 })
303 } else { 303 } else {
304 toastr.error('' + result.statusText + '', { 304 toastr.error('' + result.statusText + '', {
305 closeButton: true 305 closeButton: true
306 }) 306 })
307 } 307 }
308 }) 308 })
309 $scope.showLoader = false; 309 $scope.showLoader = false;
310 } 310 }
311 311
312 getData(); 312 getData();
313 313
314 function getData() { 314 function getData() {
315 $scope.showLoader = true; 315 $scope.showLoader = true;
316 CustomersService.getAircraftMake().then(function(result) { 316 CustomersService.getAircraftMake().then(function(result) {
317 $scope.aircraftMakeList = result; 317 $scope.aircraftMakeList = result;
318 // console.log("make",result) 318 // console.log("make",result)
319 }) 319 })
320 $scope.showLoader = false; 320 $scope.showLoader = false;
321 } 321 }
322 322
323 $scope.clearAircrafts = function() { 323 $scope.clearAircrafts = function() {
324 $scope.aircraftDetails = []; 324 $scope.aircraftDetails = [];
325 $scope.aircraftDetails = [{ 325 $scope.aircraftDetails = [{
326 'tail': '', 326 'tail': '',
327 'make': '', 327 'make': '',
328 'model': '', 328 'model': '',
329 'sizeId': '', 329 'sizeId': '',
330 'marginId': '', 330 'marginId': '',
331 'avgasMarginId': '' 331 'avgasMarginId': ''
332 }]; 332 }];
333 } 333 }
334 334
335 $scope.addNew = function() { 335 $scope.addNew = function() {
336 $scope.aircraftDetails.push({ 336 $scope.aircraftDetails.push({
337 'tail': '', 337 'tail': '',
338 'make': '', 338 'make': '',
339 'model': '', 339 'model': '',
340 'sizeId': '', 340 'sizeId': '',
341 'marginId': '', 341 'marginId': '',
342 'avgasMarginId': '' 342 'avgasMarginId': ''
343 }); 343 });
344 // console.log($scope.aircraftDetails) 344 // console.log($scope.aircraftDetails)
345 }; 345 };
346 346
347 $scope.getModal = function(makeId, index) { 347 $scope.getModal = function(makeId, index) {
348 $scope.showLoader = true; 348 $scope.showLoader = true;
349 $scope.aircraft.make = makeId; 349 $scope.aircraft.make = makeId;
350 CustomersService.getModal($scope.aircraft.make).then(function(result) { 350 CustomersService.getModal($scope.aircraft.make).then(function(result) {
351 $scope.showLoader = false; 351 $scope.showLoader = false;
352 $scope.aircraftDetails[index].aircraftModalList = result; 352 $scope.aircraftDetails[index].aircraftModalList = result;
353 //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; 353 //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0];
354 }) 354 })
355 } 355 }
356 356
357 $scope.selectedOption = ''; 357 $scope.selectedOption = '';
358 $scope.getSize = function(model, index) { 358 $scope.getSize = function(model, index) {
359 $scope.showLoader = true; 359 $scope.showLoader = true;
360 $scope.aircraft.model = model; 360 $scope.aircraft.model = model;
361 CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { 361 CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) {
362 $scope.showLoader = false; 362 $scope.showLoader = false;
363 $scope.aircraftDetails[index].aircraftSizeList = result; 363 $scope.aircraftDetails[index].aircraftSizeList = result;
364 $scope.getFuelType($scope.aircraftDetails[index].aircraftSizeList[0].aircraftSize.id,index); 364 $scope.getFuelType($scope.aircraftDetails[index].aircraftSizeList[0].aircraftSize.id,index);
365 365
366
366 }) 367 })
367 } 368 }
368 369
369 $scope.getFuelType = function(size, index) { 370 $scope.getFuelType = function(size, index) {
370 $scope.showLoader = true; 371 $scope.showLoader = true;
371 var data = "model="+$scope.aircraft.model+"&make="+$scope.aircraft.make+"&sizeId="+size; 372 var data = "model="+$scope.aircraft.model+"&make="+$scope.aircraft.make+"&sizeId="+size;
372 ViewCompanyService.checkFuelType(data).then(function(result){ 373 ViewCompanyService.checkFuelType(data).then(function(result){
373 $scope.showLoader = false; 374 $scope.showLoader = false;
374 if (result.type == "JetA") { 375 if (result.type == "JetA") {
375 $scope.jetShow[index] = false; 376 $scope.jetShow[index] = false;
376 $scope.marginShow[index] = true; 377 $scope.marginShow[index] = true;
377 } else if (result.type == "Avgas") { 378 } else if (result.type == "Avgas") {
378 $scope.jetShow[index] = true; 379 $scope.jetShow[index] = true;
379 $scope.marginShow[index] = false; 380 $scope.marginShow[index] = false;
380 }else { 381 }else {
381 $scope.jetShow[index] = true; 382 $scope.jetShow[index] = true;
382 $scope.marginShow[index] = true; 383 $scope.marginShow[index] = true;
383 } 384 }
384 }) 385 })
385 } 386 }
386 387
387 $scope.aircraftListData = {}; 388 $scope.aircraftListData = {};
388 $scope.addData = []; 389 $scope.addData = [];
389 $scope.tailArray = []; 390 $scope.tailArray = [];
390 function check(array){ 391 function check(array){
391 return (new Set(array)).size !== array.length; 392 return (new Set(array)).size !== array.length;
392 } 393 }
393 $scope.saveCompanyData = function() { 394 $scope.saveCompanyData = function() {
394 $scope.tailArray = []; 395 $scope.tailArray = [];
395 for (var i = 0; i < $scope.aircraftDetails.length; i++) { 396 for (var i = 0; i < $scope.aircraftDetails.length; i++) {
396 $scope.addData.push({ 397 $scope.addData.push({
397 'tail': $scope.aircraftDetails[i].tail, 398 'tail': $scope.aircraftDetails[i].tail,
398 'make': $scope.aircraftDetails[i].make, 399 'make': $scope.aircraftDetails[i].make,
399 'model': $scope.aircraftDetails[i].model, 400 'model': $scope.aircraftDetails[i].model,
400 'sizeId': $scope.aircraftDetails[i].sizeId, 401 'sizeId': $scope.aircraftDetails[i].sizeId,
401 'marginId': $scope.aircraftDetails[i].marginId, 402 'marginId': $scope.aircraftDetails[i].marginId,
402 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId 403 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId
403 }); 404 });
404 $scope.tailArray.push($scope.aircraftDetails[i].tail); 405 $scope.tailArray.push($scope.aircraftDetails[i].tail);
405 } 406 }
406 if (check($scope.tailArray)) { 407 if (check($scope.tailArray)) {
407 toastr.error('Duplicate Tail Added.', { 408 toastr.error('Duplicate Tail Added.', {
408 closeButton: true 409 closeButton: true
409 }) 410 })
410 }else{ 411 }else{
411 $scope.aircraftListData.aircraftList = $scope.addData; 412 $scope.aircraftListData.aircraftList = $scope.addData;
412 $scope.aircraftListData.accountId = companyId; 413 $scope.aircraftListData.accountId = companyId;
413 CustomersService.addAircraft($scope.aircraftListData).then(function(result) { 414 CustomersService.addAircraft($scope.aircraftListData).then(function(result) {
414 if (result != null && result.success) { 415 if (result != null && result.success) {
415 toastr.success('' + result.success + '', { 416 toastr.success('' + result.success + '', {
416 closeButton: true 417 closeButton: true
417 }) 418 })
419 $scope.addData= [];
420 $scope.tailArray = [];
421 $scope.aircraftListData={};
418 $('#aircraft-modal-3').css('display', 'none'); 422 $('#aircraft-modal-3').css('display', 'none');
419 $('.modal-backdrop').css('display', 'none'); 423 $('.modal-backdrop').css('display', 'none');
424
420 getAircraftList(); 425 getAircraftList();
421 } else { 426 } else {
422 toastr.error('' + result.statusText + '', { 427 toastr.error('' + result.statusText + '', {
423 closeButton: true 428 closeButton: true
424 }) 429 })
425 } 430 }
426 }); 431 });
427 } 432 }
428 433
429 } 434 }
430 435
431 $scope.showNoteData = true; 436 $scope.showNoteData = true;
432 $scope.showCompanyName = true; 437 $scope.showCompanyName = true;
433 $scope.showAddress = true; 438 $scope.showAddress = true;
434 $scope.showNote = function() { 439 $scope.showNote = function() {
435 $scope.showNoteData = false; 440 $scope.showNoteData = false;
436 $scope.showUpdateBtn = true; 441 $scope.showUpdateBtn = true;
437 } 442 }
438 443
439 $scope.company = function() { 444 $scope.company = function() {
440 $scope.showCompanyName = false; 445 $scope.showCompanyName = false;
441 $scope.showUpdateBtn = true; 446 $scope.showUpdateBtn = true;
442 } 447 }
443 448
444 $scope.base = function() { 449 $scope.base = function() {
445 $scope.showUpdateBtn = true; 450 $scope.showUpdateBtn = true;
446 } 451 }
447 452
448 $scope.addressChange = function() { 453 $scope.addressChange = function() {
449 $scope.showAddress = false; 454 $scope.showAddress = false;
450 $scope.showUpdateBtn = true; 455 $scope.showUpdateBtn = true;
451 } 456 }
452 457
453 $scope.editData = function(inputName) { 458 $scope.editData = function(inputName) {
454 //console.log($scope.companyData) 459 //console.log($scope.companyData)
455 $scope.showLoader = true; 460 $scope.showLoader = true;
456 /*if(inputName == 'showNoteData'){ 461 /*if(inputName == 'showNoteData'){
457 $scope.showNoteData = true; 462 $scope.showNoteData = true;
458 }else if(inputName == 'showCompanyName'){ 463 }else if(inputName == 'showCompanyName'){
459 $scope.showCompanyName = true; 464 $scope.showCompanyName = true;
460 }else if(inputName == 'showAddress'){ 465 }else if(inputName == 'showAddress'){
461 $scope.showAddress = true; 466 $scope.showAddress = true;
462 }*/ 467 }*/
463 $scope.showNoteData = true; 468 $scope.showNoteData = true;
464 $scope.showCompanyName = true; 469 $scope.showCompanyName = true;
465 $scope.showAddress = true; 470 $scope.showAddress = true;
466 471
467 var companyData = "companyName=" + $scope.companyData.companyName + "&masterMargin=" + $scope.companyData.masterMargin + "&avgasMargin=" + $scope.companyData.avgasMargin + 472 var companyData = "companyName=" + $scope.companyData.companyName + "&masterMargin=" + $scope.companyData.masterMargin + "&avgasMargin=" + $scope.companyData.avgasMargin +
468 "&addressOne=" + $scope.companyData.addressOne + "&addressTwo=" + $scope.companyData.addressTwo + "&city=" + $scope.companyData.city + "&state=" + 473 "&addressOne=" + $scope.companyData.addressOne + "&addressTwo=" + $scope.companyData.addressTwo + "&city=" + $scope.companyData.city + "&state=" +
469 $scope.companyData.state + "&country=" + $scope.companyData.country + "&zipcode=" + $scope.companyData.zipcode + "&internalNote=" + 474 $scope.companyData.state + "&country=" + $scope.companyData.country + "&zipcode=" + $scope.companyData.zipcode + "&internalNote=" +
470 $scope.companyData.internalNote + "&certificateType=" + $scope.companyData.certificateType + "&baseTenant=" + $scope.companyData.baseTenant + 475 $scope.companyData.internalNote + "&certificateType=" + $scope.companyData.certificateType + "&baseTenant=" + $scope.companyData.baseTenant +
471 "&fuelerlinxCustomer=" + $scope.companyData.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.companyData.contractFuelVendor + 476 "&fuelerlinxCustomer=" + $scope.companyData.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.companyData.contractFuelVendor +
472 "&activate=" + $scope.companyData.activate + "&baseIcao=" + $scope.companyData.baseIcao + "&companyId=" + companyId + "&global=" + $scope.companyData.global; 477 "&activate=" + $scope.companyData.activate + "&baseIcao=" + $scope.companyData.baseIcao + "&companyId=" + companyId + "&global=" + $scope.companyData.global;
473 478
474 ViewCompanyService.updateCompany(companyData).then(function(result) { 479 ViewCompanyService.updateCompany(companyData).then(function(result) {
475 if (result != null && result.success) { 480 if (result != null && result.success) {
476 toastr.success('' + result.success + '', { 481 toastr.success('' + result.success + '', {
477 closeButton: true 482 closeButton: true
478 }) 483 })
479 $scope.showUpdateBtn = false; 484 $scope.showUpdateBtn = false;
480 getCompanyDetail(); 485 getCompanyDetail();
481 } else { 486 } else {
482 toastr.error('Error Updating Company', { 487 toastr.error('Error Updating Company', {
483 closeButton: true 488 closeButton: true
484 }) 489 })
485 $scope.showUpdateBtn = true; 490 $scope.showUpdateBtn = true;
486 } 491 }
487 $scope.showLoader = false; 492 $scope.showLoader = false;
488 }) 493 })
489 } 494 }
490 495
491 $scope.cancelUpdateData = function() { 496 $scope.cancelUpdateData = function() {
492 $scope.showNoteData = true; 497 $scope.showNoteData = true;
493 $scope.showCompanyName = true; 498 $scope.showCompanyName = true;
494 $scope.showAddress = true; 499 $scope.showAddress = true;
495 $scope.showUpdateBtn = false; 500 $scope.showUpdateBtn = false;
496 } 501 }
497 502
498 $scope.sendMail = function() { 503 $scope.sendMail = function() {
499 $scope.showLoader = true; 504 $scope.showLoader = true;
500 $('#confirm1').css('display', 'none'); 505 $('#confirm1').css('display', 'none');
501 ViewCompanyService.sendMail(companyId).then(function(result) { 506 ViewCompanyService.sendMail(companyId).then(function(result) {
502 if (result != null && result.success) { 507 if (result != null && result.success) {
503 toastr.success('' + result.success + '', { 508 toastr.success('' + result.success + '', {
504 closeButton: true 509 closeButton: true
505 }) 510 })
506 } else { 511 } else {
507 toastr.error('Error Sending Email', { 512 toastr.error('Error Sending Email', {
508 closeButton: true 513 closeButton: true
509 }) 514 })
510 } 515 }
511 $scope.showLoader = false; 516 $scope.showLoader = false;
512 }) 517 })
513 } 518 }
514 519
515 $scope.openConfirmMail = function() { 520 $scope.openConfirmMail = function() {
516 $('#confirm1').css('display', 'block'); 521 $('#confirm1').css('display', 'block');
517 } 522 }
518 523
519 524
520 $scope.cancelAndCloseConfirm = function() { 525 $scope.cancelAndCloseConfirm = function() {
521 $('#confirm1').css('display', 'none'); 526 $('#confirm1').css('display', 'none');
522 } 527 }
523 528
524 $scope.primaryContact = false; 529 $scope.primaryContact = false;
525 $scope.cancelPrimaryContact = function() { 530 $scope.cancelPrimaryContact = function() {
526 $('#primaryContact').css('display', 'none'); 531 $('#primaryContact').css('display', 'none');
527 $scope.primaryContact = false; 532 $scope.primaryContact = false;
528 } 533 }
529 534
530 $scope.checkPrimaryContact = function() { 535 $scope.checkPrimaryContact = function() {
531 if ($scope.primaryContact == true) { 536 if ($scope.primaryContact == true) {
532 $scope.primaryContact = true; 537 $scope.primaryContact = true;
533 ViewCompanyService.checkPrimaryContact(companyId).then(function(result) { 538 ViewCompanyService.checkPrimaryContact(companyId).then(function(result) {
534 //console.log(result) 539 //console.log(result)
535 if (result.status == 422) { 540 if (result.status == 422) {
536 $('#primaryContact').css('display', 'block'); 541 $('#primaryContact').css('display', 'block');
537 } 542 }
538 }) 543 })
539 } 544 }
540 } 545 }
541 546
542 $scope.sendPrimaryContact = function() { 547 $scope.sendPrimaryContact = function() {
543 $('#primaryContact').css('display', 'none'); 548 $('#primaryContact').css('display', 'none');
544 if ($scope.primayData.id != null || $scope.primayData.id != undefined) { 549 if ($scope.primayData.id != null || $scope.primayData.id != undefined) {
545 var priamryContactData = "companyContactId=" + $scope.primayData.id + "&primary=" + $scope.primaryContact; 550 var priamryContactData = "companyContactId=" + $scope.primayData.id + "&primary=" + $scope.primaryContact;
546 551
547 ViewCompanyService.addPrimaryContact(priamryContactData).then(function(result) { 552 ViewCompanyService.addPrimaryContact(priamryContactData).then(function(result) {
548 // console.log(result) 553 // console.log(result)
549 }) 554 })
550 } 555 }
551 556
552 } 557 }
553 558
554 $scope.updateData = "" 559 $scope.updateData = ""
555 $scope.showUpdateContact = function(data, value) { 560 $scope.showUpdateContact = function(data, value) {
556 $('#updateContact').css('display', 'block'); 561 $('#updateContact').css('display', 'block');
557 $scope.updateData = data; 562 $scope.updateData = data;
558 // console.log($scope.updateData) 563 // console.log($scope.updateData)
559 if ($scope.updateData.email == null) { 564 if ($scope.updateData.email == null) {
560 $scope.updateData.content = data.contactNumber; 565 $scope.updateData.content = data.contactNumber;
561 } else { 566 } else {
562 $scope.updateData.content = data.email; 567 $scope.updateData.content = data.email;
563 } 568 }
564 } 569 }
565 570
566 $scope.showUpdateEmail = function(data, value) { 571 $scope.showUpdateEmail = function(data, value) {
567 $('#updateEmail').css('display', 'block'); 572 $('#updateEmail').css('display', 'block');
568 $scope.updateData = data; 573 $scope.updateData = data;
569 // console.log($scope.updateData) 574 // console.log($scope.updateData)
570 if ($scope.updateData.email == null) { 575 if ($scope.updateData.email == null) {
571 $scope.updateData.content = data.contactNumber; 576 $scope.updateData.content = data.contactNumber;
572 } else { 577 } else {
573 $scope.updateData.content = data.email; 578 $scope.updateData.content = data.email;
574 } 579 }
575 } 580 }
576 581
577 $scope.acceptUpdateField = function(newContactName) { 582 $scope.acceptUpdateField = function(newContactName) {
578 // console.log($scope.updateData) 583 // console.log($scope.updateData)
579 if ($scope.updateData.content == undefined) { 584 if ($scope.updateData.content == undefined) {
580 toastr.error('Please add some content', { 585 toastr.error('Please add some content', {
581 closeButton: true 586 closeButton: true
582 }) 587 })
583 } else { 588 } else {
584 if (newContactName == 'phone') { 589 if (newContactName == 'phone') {
585 var updateCustomData = "companyId=" + companyId + "&contactNumber=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + 590 var updateCustomData = "companyId=" + companyId + "&contactNumber=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id +
586 "&title=" + $scope.updateData.title; 591 "&title=" + $scope.updateData.title;
587 } else { 592 } else {
588 var updateCustomData = "companyId=" + companyId + "&email=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + 593 var updateCustomData = "companyId=" + companyId + "&email=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id +
589 "&title=" + $scope.updateData.title; 594 "&title=" + $scope.updateData.title;
590 } 595 }
591 ViewCompanyService.updateCustomField(updateCustomData).then(function(result) { 596 ViewCompanyService.updateCustomField(updateCustomData).then(function(result) {
592 if (result != null && result.success) { 597 if (result != null && result.success) {
593 $('#updateContact').css('display', 'none'); 598 $('#updateContact').css('display', 'none');
594 $('#updateEmail').css('display', 'none'); 599 $('#updateEmail').css('display', 'none');
595 getCompanyDetail(); 600 getCompanyDetail();
596 } 601 }
597 }) 602 })
598 } 603 }
599 } 604 }
600 605
601 $scope.deleteContent = function(data){ 606 $scope.deleteContent = function(data){
602 ViewCompanyService.deleteCustomContact(data.id).then(function(result) { 607 ViewCompanyService.deleteCustomContact(data.id).then(function(result) {
603 if (result != null && result.success) { 608 if (result != null && result.success) {
604 toastr.success('' + result.success + '', { 609 toastr.success('' + result.success + '', {
605 closeButton: true 610 closeButton: true
606 }) 611 })
607 getCompanyDetail(); 612 getCompanyDetail();
608 } 613 }
609 }) 614 })
610 } 615 }
611 616
612 $scope.cancelUpdateField = function() { 617 $scope.cancelUpdateField = function() {
613 $('#updateContact').css('display', 'none'); 618 $('#updateContact').css('display', 'none');
614 $('#updateEmail').css('display', 'none'); 619 $('#updateEmail').css('display', 'none');
615 } 620 }
616 621
617 $scope.showEditTier2 = function(number) { 622 $scope.showEditTier2 = function(number) {
618 // console.log(number) 623 // console.log(number)
619 $scope.contactNumber = number; 624 $scope.contactNumber = number;
620 } 625 }
621 626
622 627
623 628
624 $scope.addCustomPhone = function(value) { 629 $scope.addCustomPhone = function(value) {
625 //console.log(value) 630 //console.log(value)
626 if (value != null) { 631 if (value != null) {
627 $('#customFieldPhone').css('display', 'block'); 632 $('#customFieldPhone').css('display', 'block');
628 } 633 }
629 $scope.custom = {}; 634 $scope.custom = {};
630 } 635 }
631 636
632 $scope.addCustomEmail = function(value) { 637 $scope.addCustomEmail = function(value) {
633 //console.log(value) 638 //console.log(value)
634 if (value != null) { 639 if (value != null) {
635 $('#customFieldEmail').css('display', 'block'); 640 $('#customFieldEmail').css('display', 'block');
636 } 641 }
637 $scope.custom = {}; 642 $scope.custom = {};
638 } 643 }
639 644
640 $scope.cancelCustomField = function() { 645 $scope.cancelCustomField = function() {
641 $('#customFieldEmail').css('display', 'none'); 646 $('#customFieldEmail').css('display', 'none');
642 $('#customFieldPhone').css('display', 'none'); 647 $('#customFieldPhone').css('display', 'none');
643 } 648 }
644 649
645 $scope.acceptCustomField = function(contactName) { 650 $scope.acceptCustomField = function(contactName) {
646 if ($scope.custom.content == undefined) { 651 if ($scope.custom.content == undefined) {
647 toastr.error('Please add some content', { 652 toastr.error('Please add some content', {
648 closeButton: true 653 closeButton: true
649 }) 654 })
650 } else { 655 } else {
651 if (contactName == 'phone') { 656 if (contactName == 'phone') {
652 var customData = "companyId=" + companyId + "&contactNumber=" + $scope.custom.content + 657 var customData = "companyId=" + companyId + "&contactNumber=" + $scope.custom.content +
653 "&title=" + $scope.custom.title; 658 "&title=" + $scope.custom.title;
654 } else { 659 } else {
655 var customData = "companyId=" + companyId + "&email=" + $scope.custom.content + 660 var customData = "companyId=" + companyId + "&email=" + $scope.custom.content +
656 "&title=" + $scope.custom.title; 661 "&title=" + $scope.custom.title;
657 } 662 }
658 // console.log(customData.email) 663 // console.log(customData.email)
659 ViewCompanyService.addCustomField(customData).then(function(result) { 664 ViewCompanyService.addCustomField(customData).then(function(result) {
660 // console.log(result) 665 // console.log(result)
661 if (result != null && result.success) { 666 if (result != null && result.success) {
662 $('#customFieldEmail').css('display', 'none'); 667 $('#customFieldEmail').css('display', 'none');
663 $('#customFieldPhone').css('display', 'none'); 668 $('#customFieldPhone').css('display', 'none');
664 $scope.custom = {}; 669 $scope.custom = {};
665 getCompanyDetail(); 670 getCompanyDetail();
666 } 671 }
667 }) 672 })
668 } 673 }
669 } 674 }
670 675
671 /* omit strike out*/ 676 /* omit strike out*/
672 updateFuelManagerService.getFuelPricingNew().then(function(result) { 677 updateFuelManagerService.getFuelPricingNew().then(function(result) {
673 $scope.fuelPricing = result; 678 $scope.fuelPricing = result;
674 $scope.omitData; 679 $scope.omitData;
675 ViewCompanyService.getOmitCompany($scope.compId).then(function(result){ 680 ViewCompanyService.getOmitCompany($scope.compId).then(function(result){
676 $scope.omitData = result; 681 $scope.omitData = result;
677 //console.log("omit data===", $scope.omitData); 682 //console.log("omit data===", $scope.omitData);
678 for(var i = 0 ; i< $scope.fuelPricing.length; i++){ 683 for(var i = 0 ; i< $scope.fuelPricing.length; i++){
679 for(var j = 0; j<$scope.omitData.length; j++){ 684 for(var j = 0; j<$scope.omitData.length; j++){
680 if($scope.omitData[j].marginId == $scope.fuelPricing[i].fuelPricing.id){ 685 if($scope.omitData[j].marginId == $scope.fuelPricing[i].fuelPricing.id){
681 $scope.fuelPricing[i].fuelPricing.omit = $scope.omitData[j].omit; 686 $scope.fuelPricing[i].fuelPricing.omit = $scope.omitData[j].omit;
682 } 687 }
683 } 688 }
684 } 689 }
685 690
686 }) 691 })
687 692
688 // console.log("$scope.fuelPricing",$scope.fuelPricing) 693 // console.log("$scope.fuelPricing",$scope.fuelPricing)
689 for (var i = 0; i < $scope.fuelPricing.length; i++) { 694 for (var i = 0; i < $scope.fuelPricing.length; i++) {
690 // console.log('$scope.fuelPricing[i].fuelPricing', $scope.fuelPricing[i].fuelPricing); 695 // console.log('$scope.fuelPricing[i].fuelPricing', $scope.fuelPricing[i].fuelPricing);
691 //console.log("fuelid",$scope.fuelPricing[i].fuelPricing.id,"getid",$scope.omitData[j].id) 696 //console.log("fuelid",$scope.fuelPricing[i].fuelPricing.id,"getid",$scope.omitData[j].id)
692 if ($scope.fuelPricing[i].fuelPricing.expirationDate != null) { 697 if ($scope.fuelPricing[i].fuelPricing.expirationDate != null) {
693 $scope.fuelPricing[i].fuelPricing.expirationDate = new Date($scope.fuelPricing[i].fuelPricing.expirationDate); 698 $scope.fuelPricing[i].fuelPricing.expirationDate = new Date($scope.fuelPricing[i].fuelPricing.expirationDate);
694 var newTime = new Date($scope.fuelPricing[i].fuelPricing.expirationDate); 699 var newTime = new Date($scope.fuelPricing[i].fuelPricing.expirationDate);
695 var dmonth = newTime.getUTCMonth() + 1; //months from 1-12 700 var dmonth = newTime.getUTCMonth() + 1; //months from 1-12
696 var dday = newTime.getUTCDate(); 701 var dday = newTime.getUTCDate();
697 var dyear = newTime.getUTCFullYear(); 702 var dyear = newTime.getUTCFullYear();
698 $scope.fuelPricing[i].fuelPricing.expirationDate = dmonth + '/' + dday + '/' + dyear; 703 $scope.fuelPricing[i].fuelPricing.expirationDate = dmonth + '/' + dday + '/' + dyear;
699 } 704 }
700 // for (var j = 0; j<$scope.omitData.length; j++) { 705 // for (var j = 0; j<$scope.omitData.length; j++) {
701 // if($scope.fuelPricing[i].fuelPricing.id === $scope.omitData[j].id){ 706 // if($scope.fuelPricing[i].fuelPricing.id === $scope.omitData[j].id){
702 707
703 // } 708 // }
704 // } 709 // }
705 } 710 }
706 }) 711 })
707 712
708 var deleteAircraftId = ""; 713 var deleteAircraftId = "";
709 $scope.deleteAircraft = function(id) { 714 $scope.deleteAircraft = function(id) {
710 $('#delete1').css('display', 'block'); 715 $('#delete1').css('display', 'block');
711 deleteAircraftId = id; 716 deleteAircraftId = id;
712 } 717 }
713 718
714 $scope.aircraftDelete = function() { 719 $scope.aircraftDelete = function() {
715 ViewCompanyService.deleteAircraft(deleteAircraftId).then(function(result) { 720 ViewCompanyService.deleteAircraft(deleteAircraftId).then(function(result) {
716 // console.log(result) 721 // console.log(result)
717 getAircraftList(); 722 getAircraftList();
718 getCompanyDetail(); 723 getCompanyDetail();
719 $('#delete1').css('display', 'none'); 724 $('#delete1').css('display', 'none');
720 }) 725 })
721 } 726 }
722 727
723 $scope.cancelAircraft = function() { 728 $scope.cancelAircraft = function() {
724 $('#delete1').css('display', 'none'); 729 $('#delete1').css('display', 'none');
725 } 730 }
726 731
727 CustomersService.getJetMargin($scope.userProfileId).then(function(result) { 732 CustomersService.getJetMargin($scope.userProfileId).then(function(result) {
728 $scope.jetMarginList = result; 733 $scope.jetMarginList = result;
729 }) 734 })
730 735
731 CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { 736 CustomersService.getAvgMargin($scope.userProfileId).then(function(result) {
732 $scope.avgsMarginList = result; 737 $scope.avgsMarginList = result;
733 }) 738 })
734 739
735 $scope.changePriceEmail = function(id, index) { 740 $scope.changePriceEmail = function(id, index) {
736 event.stopPropagation(); 741 event.stopPropagation();
737 var contactId = id; 742 var contactId = id;
738 var statusData = "status=" + $scope.companyContactList[index].priceEmail; 743 var statusData = "status=" + $scope.companyContactList[index].priceEmail;
739 ViewcontactService.changePriceEmail(contactId, statusData).then(function(result) { 744 ViewcontactService.changePriceEmail(contactId, statusData).then(function(result) {
740 if (result.success) { 745 if (result.success) {
741 $('#toogleMail').css('display', 'block'); 746 $('#toogleMail').css('display', 'block');
742 if ($scope.companyContactList[index].priceEmail == true) { 747 if ($scope.companyContactList[index].priceEmail == true) {
743 $scope.messageText = 'You have enabled price distribution for this contact'; 748 $scope.messageText = 'You have enabled price distribution for this contact';
744 } else { 749 } else {
745 $scope.messageText = 'You have disabled price distribution for this contact'; 750 $scope.messageText = 'You have disabled price distribution for this contact';
746 } 751 }
747 } 752 }
748 }) 753 })
749 } 754 }
750 755
751 $scope.cancelToogle = function() { 756 $scope.cancelToogle = function() {
752 $('#toogleMail').css('display', 'none'); 757 $('#toogleMail').css('display', 'none');
753 } 758 }
754 759
755 $scope.checkboxStatus = function(value) { 760 $scope.checkboxStatus = function(value) {
756 // console.log("checkbox",value) 761 // console.log("checkbox",value)
757 $scope.showUpdateBtn = true; 762 $scope.showUpdateBtn = true;
758 } 763 }
759 764
760 $scope.fuelercheckboxStatus = function(value) { 765 $scope.fuelercheckboxStatus = function(value) {
761 $('#fuelerchange').css('display', 'block'); 766 $('#fuelerchange').css('display', 'block');
762 if (value == true) { 767 if (value == true) {
763 $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' 768 $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'
764 } else { 769 } else {
765 $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.' 770 $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.'
766 } 771 }
767 772
768 773
769 } 774 }
770 775
771 $scope.fuelerCancelStatus = function() { 776 $scope.fuelerCancelStatus = function() {
772 $('#fuelerchange').css('display', 'none'); 777 $('#fuelerchange').css('display', 'none');
773 $scope.companyData.fuelerlinxCustomer = !$scope.companyData.fuelerlinxCustomer; 778 $scope.companyData.fuelerlinxCustomer = !$scope.companyData.fuelerlinxCustomer;
774 } 779 }
775 780
776 $scope.fuelerAcceptStatus = function() { 781 $scope.fuelerAcceptStatus = function() {
777 $('#fuelerchange').css('display', 'none'); 782 $('#fuelerchange').css('display', 'none');
778 $scope.showLoader = true; 783 $scope.showLoader = true;
779 var statusData; 784 var statusData;
780 if ($scope.companyData.fuelerlinxCustomer == false) { 785 if ($scope.companyData.fuelerlinxCustomer == false) {
781 statusData = "status=true"; 786 statusData = "status=true";
782 } else { 787 } else {
783 statusData = "status=false"; 788 statusData = "status=false";
784 } 789 }
785 ViewCompanyService.fuelerPricingChange(companyId, statusData).then(function(result) { 790 ViewCompanyService.fuelerPricingChange(companyId, statusData).then(function(result) {
786 if (result.success) { 791 if (result.success) {
787 $scope.showLoader = false; 792 $scope.showLoader = false;
788 793
789 $scope.editData(); 794 $scope.editData();
790 getContactList(); 795 getContactList();
791 796
792 } 797 }
793 }) 798 })
794 } 799 }
795 800
796 801
797 $scope.updateOmit = function(fuel, omit) { 802 $scope.updateOmit = function(fuel, omit) {
798 $scope.fuelData = {}; 803 $scope.fuelData = {};
799 $scope.fuelData.expirationDate = new Date(fuel.expirationDate); 804 $scope.fuelData.expirationDate = new Date(fuel.expirationDate);
800 $scope.fuelData.customMarginId = fuel.id; 805 $scope.fuelData.customMarginId = fuel.id;
801 $scope.fuelData.omit = fuel.omit; 806 $scope.fuelData.omit = fuel.omit;
802 $scope.fuelData.papMargin = fuel.papMargin; 807 $scope.fuelData.papMargin = fuel.papMargin;
803 $scope.fuelData.papTotal = fuel.papTotal; 808 $scope.fuelData.papTotal = fuel.papTotal;
804 $scope.fuelData.cost = fuel.cost; 809 $scope.fuelData.cost = fuel.cost;
805 $scope.fuelData.companyId = $scope.compId ; 810 $scope.fuelData.companyId = $scope.compId ;
806 if($scope.fuelData.omit == true) 811 if($scope.fuelData.omit == true)
807 { 812 {
808 var customData = "companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId; 813 var customData = "companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId;
809 ViewCompanyService.omitAddCompanyFuel(customData).then(function(result) { 814 ViewCompanyService.omitAddCompanyFuel(customData).then(function(result) {
810 if (result.success) { 815 if (result.success) {
811 toastr.success('' + result.success + '', { 816 toastr.success('' + result.success + '', {
812 closeButton: true 817 closeButton: true
813 }) 818 })
814 } else { 819 } else {
815 toastr.error('' + result.statusText + '', { 820 toastr.error('' + result.statusText + '', {
816 closeButton: true 821 closeButton: true
817 }) 822 })
818 } 823 }
819 }) 824 })
820 }else{ 825 }else{
821 var data ="companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId; 826 var data ="companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId;
822 ViewCompanyService.omitDeleteCompanyFuel(data).then(function(result){ 827 ViewCompanyService.omitDeleteCompanyFuel(data).then(function(result){
823 if (result.success) { 828 if (result.success) {
824 toastr.success('' + result.success + '', { 829 toastr.success('' + result.success + '', {
825 closeButton: true 830 closeButton: true
826 }) 831 })
827 } else { 832 } else {
828 toastr.error('' + result.statusText + '', { 833 toastr.error('' + result.statusText + '', {
829 closeButton: true 834 closeButton: true
830 }) 835 })
831 } 836 }
832 }) 837 })
833 } 838 }
834 } 839 }
835 840
836 841
837 //--fuel type based on tail is not in use-- 842 //--fuel type based on tail is not in use--
838 // $scope.aircraftData = {} 843 // $scope.aircraftData = {}
839 /*$scope.checkJetWithTail = function(tail, index) { 844 /*$scope.checkJetWithTail = function(tail, index) {
840 845
841 console.log("tail==============",tail, index) 846 console.log("tail==============",tail, index)
842 ViewCompanyService.checkJetType(tail).then(function(result) { 847 ViewCompanyService.checkJetType(tail).then(function(result) {
843 console.log("result",result) 848 console.log("result",result)
844 if (result.jetA == "true") { 849 if (result.jetA == "true") {
845 $scope.jetShow[index] = false; 850 $scope.jetShow[index] = false;
846 $scope.marginShow[index] = true; 851 $scope.marginShow[index] = true;
847 } else { 852 } else {
848 $scope.jetShow[index] = true; 853 $scope.jetShow[index] = true;
849 $scope.marginShow[index] = false; 854 $scope.marginShow[index] = false;
850 } 855 }
851 }) 856 })
852 }*/ 857 }*/
853 858
854 859
855 /*add a fuel order*/ 860 /*add a fuel order*/
856 861
857 862
858 $scope.getOrders = function() { 863 $scope.getOrders = function() {
859 fuelOrdersService.getOrders().then(function(result) { 864 fuelOrdersService.getOrders().then(function(result) {
860 865
861 $scope.orderdata = result; 866 $scope.orderdata = result;
862 for (var i = 0; i < $scope.orderdata.length; i++) { 867 for (var i = 0; i < $scope.orderdata.length; i++) {
863 $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); 868 $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate);
864 869
865 // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear() 870 // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear()
866 var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear() 871 var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear()
867 // str = str.slice(4,16) 872 // str = str.slice(4,16)
868 $scope.orderdata[i].upliftDateString = str 873 $scope.orderdata[i].upliftDateString = str
869 // console.log(str); 874 // console.log(str);
870 875
871 } 876 }
872 877
873 $scope.displayFuelOrderList = new NgTableParams({ 878 $scope.displayFuelOrderList = new NgTableParams({
874 page: 1, 879 page: 1,
875 count: 10, 880 count: 10,
876 }, { 881 }, {
877 data: $scope.orderdata 882 data: $scope.orderdata
878 }); 883 });
879 $(document).ready(function() { 884 $(document).ready(function() {
880 var myselect = document.getElementsByClassName('colorfulSelectbox'); 885 var myselect = document.getElementsByClassName('colorfulSelectbox');
881 886
882 for (var i = 0; i < myselect.length; i++) { 887 for (var i = 0; i < myselect.length; i++) {
883 var colourIndex = $(myselect[i]).prop('selectedIndex'); 888 var colourIndex = $(myselect[i]).prop('selectedIndex');
884 colourIndex = colourIndex + 1; 889 colourIndex = colourIndex + 1;
885 // console.log(colourIndex); 890 // console.log(colourIndex);
886 var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color'); 891 var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color');
887 $(myselect[i]).css('background-color', getColor); 892 $(myselect[i]).css('background-color', getColor);
888 // console.log('colour', getColor); 893 // console.log('colour', getColor);
889 myselect[i].blur(); 894 myselect[i].blur();
890 } 895 }
891 896
892 }) 897 })
893 898
894 }) 899 })
895 } 900 }
896 901
897 $scope.getOrders(); 902 $scope.getOrders();
898 903
899 $scope.tiervalue=function(){ 904 $scope.tiervalue=function(){
900 $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; 905 $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak;
901 } 906 }
902 907
903 $scope.setCost = function(cost){ 908 $scope.setCost = function(cost){
904 if(cost != null) { 909 if(cost != null) {
905 var obj =JSON.parse(cost); 910 var obj =JSON.parse(cost);
906 $scope.order.fboCost = obj.cost; 911 $scope.order.fboCost = obj.cost;
907 } 912 }
908 } 913 }
909 914
910 $scope.cancelOrder = function() { 915 $scope.cancelOrder = function() {
911 $scope.order = {}; 916 $scope.order = {};
912 } 917 }
913 918
914 $scope.dispatchFuel = function(){ 919 $scope.dispatchFuel = function(){
915 $scope.showLoader = true; 920 $scope.showLoader = true;
916 $scope.order.companyId = $scope.compId; 921 $scope.order.companyId = $scope.compId;
917 if ($scope.order.upliftDate != '') { 922 if ($scope.order.upliftDate != '') {
918 var currentDate = new Date(); 923 var currentDate = new Date();
919 var hours = currentDate.getHours(); 924 var hours = currentDate.getHours();
920 var min = currentDate.getMinutes(); 925 var min = currentDate.getMinutes();
921 var sec = currentDate.getSeconds(); 926 var sec = currentDate.getSeconds();
922 $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; 927 $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec;
923 $scope.order.upliftDate = new Date($scope.order.upliftDate); 928 $scope.order.upliftDate = new Date($scope.order.upliftDate);
924 $scope.order.upliftDate = $scope.order.upliftDate.getTime(); 929 $scope.order.upliftDate = $scope.order.upliftDate.getTime();
925 } 930 }
926 $scope.order.status = 'pending'; 931 $scope.order.status = 'pending';
927 var obj =JSON.parse($scope.order.priceQuote); 932 var obj =JSON.parse($scope.order.priceQuote);
928 $scope.order.priceQuote = obj.papTotal; 933 $scope.order.priceQuote = obj.papTotal;
929 $scope.order.fboCost = obj.cost; 934 $scope.order.fboCost = obj.cost;
930 $scope.order.total = obj.papTotal * $scope.order.volume; 935 $scope.order.total = obj.papTotal * $scope.order.volume;
931 var aircraftObj =JSON.parse($scope.order.aircraftName); 936 var aircraftObj =JSON.parse($scope.order.aircraftName);
932 $scope.order.aircraftName = aircraftObj.tail; 937 $scope.order.aircraftName = aircraftObj.tail;
933 $scope.order.make = aircraftObj.make; 938 $scope.order.make = aircraftObj.make;
934 $scope.order.model = aircraftObj.model; 939 $scope.order.model = aircraftObj.model;
935 $scope.dispatchOrder.fuelOrderList.push($scope.order); 940 $scope.dispatchOrder.fuelOrderList.push($scope.order);
936 enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { 941 enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
937 $scope.showLoader = false; 942 $scope.showLoader = false;
938 $scope.order = {}; 943 $scope.order = {};
939 $('#demo-modal-4').css('display', ''); 944 $('#demo-modal-4').css('display', '');
940 toastr.success('Fuel Order Dispatched Successfully', { 945 toastr.success('Fuel Order Dispatched Successfully', {
941 closeButton: true 946 closeButton: true
942 }) 947 })
943 }) 948 })
944 } 949 }
945 950
946 $scope.addTotal = function(value, valueOf) { 951 $scope.addTotal = function(value, valueOf) {
947 if (valueOf == 'v') { 952 if (valueOf == 'v') {
948 $scope.order.total = value * $scope.order.invoiced 953 $scope.order.total = value * $scope.order.invoiced
949 } else if (valueOf == 'i') { 954 } else if (valueOf == 'i') {
950 $scope.order.total = $scope.order.volume * value 955 $scope.order.total = $scope.order.volume * value
951 } 956 }
952 } 957 }
953 958
954 $scope.getAircraft = function(company) { 959 $scope.getAircraft = function(company) {
955 $scope.selectedCompanyName = company; 960 $scope.selectedCompanyName = company;
956 961
957 if ($scope.companyData.margin != null && $scope.companyData.marginAVGAS != null) { 962 if ($scope.companyData.margin != null && $scope.companyData.marginAVGAS != null) {
958 fuelOrdersService.getFuelCost($scope.companyData.id).then(function(margins) { 963 fuelOrdersService.getFuelCost($scope.companyData.id).then(function(margins) {
959 $scope.marginList = margins; 964 $scope.marginList = margins;
960 //console.log('$scope.marginList', $scope.marginList); 965 //console.log('$scope.marginList', $scope.marginList);
961 }) 966 })
962 } else if ($scope.companyData.margin != null || $scope.companyData.marginAVGAS == null) { 967 } else if ($scope.companyData.margin != null || $scope.companyData.marginAVGAS == null) {
963 fuelOrdersService.getATypeFuelPricing($scope.companyData.id).then(function(margins) { 968 fuelOrdersService.getATypeFuelPricing($scope.companyData.id).then(function(margins) {
964 $scope.marginList = margins; 969 $scope.marginList = margins;
965 }) 970 })
966 } else if ($scope.companyData.margin == null || $scope.companyData.marginAVGAS != null) { 971 } else if ($scope.companyData.margin == null || $scope.companyData.marginAVGAS != null) {
967 fuelOrdersService.getVTypeFuelPricing($scope.companyData.id).then(function(margins) { 972 fuelOrdersService.getVTypeFuelPricing($scope.companyData.id).then(function(margins) {
968 $scope.marginList = margins; 973 $scope.marginList = margins;
969 }) 974 })
970 } 975 }
971 976
972 977
973 $scope.selectedCompanyId = $scope.companyData.id; 978 $scope.selectedCompanyId = $scope.companyData.id;
974 $scope.marginId = $scope.companyData.margin.id; 979 $scope.marginId = $scope.companyData.margin.id;
975 if ($scope.selectedCompanyId != '') { 980 if ($scope.selectedCompanyId != '') {
976 fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { 981 fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) {
977 $scope.aircraftList = aircraft; 982 $scope.aircraftList = aircraft;
978 }) 983 })
979 } 984 }
980 if ($scope.marginId != '') { 985 if ($scope.marginId != '') {
981 fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) { 986 fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) {
982 $scope.tierList = tiers; 987 $scope.tierList = tiers;
983 // $scope.showLoader = false; 988 // $scope.showLoader = false;
984 }) 989 })
985 } 990 }
986 991
987 } 992 }
988 993
989 $scope.setCost = function(cost) { 994 $scope.setCost = function(cost) {
990 // console.log(cost); 995 // console.log(cost);
991 if (cost != null) { 996 if (cost != null) {
992 var obj = JSON.parse(cost); 997 var obj = JSON.parse(cost);
993 // console.log("0bj",obj) 998 // console.log("0bj",obj)
994 $scope.order.fboCost = obj.cost; 999 $scope.order.fboCost = obj.cost;
995 } 1000 }
996 1001
997 } 1002 }
998 1003
999 $scope.sourceList = [{ 1004 $scope.sourceList = [{
1000 source: "Direct Jet-A" 1005 source: "Direct Jet-A"
1001 }, { 1006 }, {
1002 source: "Direct AVGAS 100LL" 1007 source: "Direct AVGAS 100LL"
1003 }]; 1008 }];
1004 $scope.cancelData = function() { 1009 $scope.cancelData = function() {
1005 $('#demo-modal-4').css('display', ''); 1010 $('#demo-modal-4').css('display', '');
1006 } 1011 }
1007 1012
1008 $scope.setFuel = function() { 1013 $scope.setFuel = function() {
1009 $('#demo-modal-4').css('display', 'block'); 1014 $('#demo-modal-4').css('display', 'block');
1010 1015
1011 } 1016 }
1012 1017
1013 /*delete company*/ 1018 /*delete company*/
1014 var deletecompanyId = ""; 1019 var deletecompanyId = "";
1015 $scope.deleteComp = function(companyDataid) { 1020 $scope.deleteComp = function(companyDataid) {
1016 $('#delete2').css('display', 'block'); 1021 $('#delete2').css('display', 'block');
1017 //console.log("asda",companyDataid) 1022 //console.log("asda",companyDataid)
1018 deletecompanyId = companyDataid; 1023 deletecompanyId = companyDataid;
1019 } 1024 }
1020 $scope.aircraftIdx = ''; 1025 $scope.aircraftIdx = '';
1021 $scope.checkTail = function(tail, idx){ 1026 $scope.checkTail = function(tail, idx){
1022 var data = "tail=" + tail + "&id=" + companyId; 1027 var data = "tail=" + tail + "&id=" + companyId;
1023 $scope.aircraftIdx = idx; 1028 $scope.aircraftIdx = idx;
1024 ViewCompanyService.checkTail(data).then(function(result) { 1029 ViewCompanyService.checkTail(data).then(function(result) {
1025 if(result.error) { 1030 if(result.error) {
1026 $scope.aircraftMessage = result.error; 1031 $scope.aircraftMessage = result.error;
1027 $scope.openAddAirCraftError(); 1032 $scope.openAddAirCraftError();
1028 } else if(result.warning) { 1033 } else if(result.warning) {
1029 $scope.aircraftMessage = result.warning; 1034 $scope.aircraftMessage = result.warning;
1030 $scope.openAddAirCraftWarning(); 1035 $scope.openAddAirCraftWarning();
1031 } 1036 }
1032 }) 1037 })
1033 } 1038 }
1034 1039
1035 $scope.openAddAirCraftError = function() { 1040 $scope.openAddAirCraftError = function() {
1036 $('#addAirCraftError').css('display', 'block'); 1041 $('#addAirCraftError').css('display', 'block');
1037 } 1042 }
1038 1043
1039 $scope.openAddAirCraftWarning = function() { 1044 $scope.openAddAirCraftWarning = function() {
1040 $('#addAirCraftWarning').css('display', 'block'); 1045 $('#addAirCraftWarning').css('display', 'block');
1041 } 1046 }
1042 $scope.acceptAirCraftError = function() { 1047 $scope.acceptAirCraftError = function() {
1043 $('#addAirCraftWarning').css('display', 'none'); 1048 $('#addAirCraftWarning').css('display', 'none');
1044 } 1049 }
1045 1050
1046 $scope.cancelAirCraftError = function() { 1051 $scope.cancelAirCraftError = function() {
1047 $scope.aircraftDetails[$scope.aircraftIdx].tail = ''; 1052 $scope.aircraftDetails[$scope.aircraftIdx].tail = '';
1048 $('#addAirCraftWarning').css('display', 'none'); 1053 $('#addAirCraftWarning').css('display', 'none');
1049 $('#addAirCraftError').css('display', 'none'); 1054 $('#addAirCraftError').css('display', 'none');
1050 } 1055 }
1051 1056
1052 $scope.deleteCompanyData = function() { 1057 $scope.deleteCompanyData = function() {
1053 ViewCompanyService.deleteCompany(deletecompanyId).then(function(result) { 1058 ViewCompanyService.deleteCompany(deletecompanyId).then(function(result) {
1054 1059
1055 $('#delete2').css('display', 'none'); 1060 $('#delete2').css('display', 'none');
1056 if (result.success) { 1061 if (result.success) {
1057 toastr.success('' + result.success + '', { 1062 toastr.success('' + result.success + '', {
1058 closeButton: true 1063 closeButton: true
1059 1064
1060 }) 1065 })
1061 } else { 1066 } else {
1062 toastr.error('' + result.statusText + '', { 1067 toastr.error('' + result.statusText + '', {
1063 closeButton: true 1068 closeButton: true
1064 1069
1065 }) 1070 })
1066 } 1071 }
1067 $state.go('app.customers') 1072 $state.go('app.customers')
1068 }) 1073 })
1069 } 1074 }
1070 $scope.cancelDelete = function() { 1075 $scope.cancelDelete = function() {
1071 $('#delete2').css('display', 'none'); 1076 $('#delete2').css('display', 'none');
1072 } 1077 }
1073 1078
1074 1079
1075 $scope.editJetMargin = function(aircraftData, type) { 1080 $scope.editJetMargin = function(aircraftData, type) {
1076 $scope.showLoader = true; 1081 $scope.showLoader = true;
1077 if (type == 'jet') { 1082 if (type == 'jet') {
1078 1083
1079 var aircraftdataMargin = "marginId=" + aircraftData.aircraftsMargin.id + "&type=" + type; 1084 var aircraftdataMargin = "marginId=" + aircraftData.aircraftsMargin.id + "&type=" + type;
1080 1085
1081 } else { 1086 } else {
1082 var aircraftdataMargin = "marginId=" + aircraftData.aircraftsAVGASMargin.id + "&type=" + type; 1087 var aircraftdataMargin = "marginId=" + aircraftData.aircraftsAVGASMargin.id + "&type=" + type;
1083 } 1088 }
1084 1089
1085 var id = aircraftData.id; 1090 var id = aircraftData.id;
1086 ViewCompanyService.updateAircraftMargin(aircraftdataMargin, id).then(function(result) { 1091 ViewCompanyService.updateAircraftMargin(aircraftdataMargin, id).then(function(result) {
1087 if (result != null && result.success) { 1092 if (result != null && result.success) {
1088 $scope.showLoader = false; 1093 $scope.showLoader = false;
1089 toastr.success('' + result.success + '', { 1094 toastr.success('' + result.success + '', {
1090 closeButton: true 1095 closeButton: true
1091 }) 1096 })
1092 // getAircraftWithMarginList(); 1097 // getAircraftWithMarginList();
1093 getAircraftList(); 1098 getAircraftList();
1094 } else { 1099 } else {
1095 $scope.showLoader = false; 1100 $scope.showLoader = false;
1096 toastr.error('' + result.statusText + '', { 1101 toastr.error('' + result.statusText + '', {
1097 closeButton: true 1102 closeButton: true
1098 }) 1103 })
1099 } 1104 }
1100 }) 1105 })
1101 } 1106 }
1102 1107
1103 1108
1104 /* //not used currently 1109 /* //not used currently
1105 function getAircraftWithMarginList() { 1110 function getAircraftWithMarginList() {
1106 ViewCompanyService.getJetAMargin(companyId).then(function(result) { 1111 ViewCompanyService.getJetAMargin(companyId).then(function(result) {
1107 $scope.contactAircraftList = result; 1112 $scope.contactAircraftList = result;
1108 for (var i = 0; i < $scope.contactAircraftList.length; i++) { 1113 for (var i = 0; i < $scope.contactAircraftList.length; i++) {
1109 if ($scope.contactAircraftList[i].aircraftsMargin != null) { 1114 if ($scope.contactAircraftList[i].aircraftsMargin != null) {
1110 $scope.aircraftmargins.push({ 1115 $scope.aircraftmargins.push({
1111 'id': $scope.contactAircraftList[i].aircraftsMargin.id 1116 'id': $scope.contactAircraftList[i].aircraftsMargin.id
1112 }) 1117 })
1113 } 1118 }
1114 } 1119 }
1115 if ($scope.aircraftmargins.length > 0) { 1120 if ($scope.aircraftmargins.length > 0) {
1116 for (var i = 0; i < $scope.aircraftmargins.length; i++) { 1121 for (var i = 0; i < $scope.aircraftmargins.length; i++) {
1117 if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) { 1122 if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) {
1118 $scope.multiple = true; 1123 $scope.multiple = true;
1119 $scope.multipleMsg = true; 1124 $scope.multipleMsg = true;
1120 if ($scope.multiple) { 1125 if ($scope.multiple) {
1121 $scope.companyData.masterMargin = "multiple"; 1126 $scope.companyData.masterMargin = "multiple";
1122 } 1127 }
1123 } 1128 }
1124 } 1129 }
1125 } 1130 }
1126 }) 1131 })
1127 }*/ 1132 }*/
1128 1133
1129 1134
1130 }]); 1135 }]);