Blame view

app/partials/viewCompany/viewCompany.controller.js 43.7 KB
feacde5ff   Rishav   setup acuefuel in...
1
  'use strict';
5983d987a   Kuldeep Arora   jetmargin api
2
3
  //Load controller
  angular.module('acufuel')
feacde5ff   Rishav   setup acuefuel in...
4

9d840540f   Anchit Jindal   fixed bugs and ne...
5
      .controller('viewCompanyController', ['$scope', '$uibModal', '$stateParams', 'ViewCompanyService', 'CustomersService', 'updateFuelManagerService', 'ViewFuelVendorService', 'ViewcontactService', '$state', 'fuelOrdersService', 'enterFuelOrderService', 'NgTableParams', function($scope, $uibModal, $stateParams, ViewCompanyService, CustomersService, updateFuelManagerService, ViewFuelVendorService, ViewcontactService, $state, fuelOrdersService, enterFuelOrderService, NgTableParams) {
55e075d7e   Rishav   add contact, add ...
6
7
          $scope.data = {};
          $scope.data.priceEmail = true;
b1f6160d4   Rishav   add contact and a...
8
          $scope.aircraft = {};
3a9f4472b   Rishav   Implement contact...
9
          $scope.primayData = {};
d24318592   Rishav   changes and new i...
10
          $scope.showLoader = false;
ba1d39503   Swarn Singh   view company form...
11
          $scope.showUpdateBtn = false;
28af27a3f   Rishav   add fuelPriceapi
12
          $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId'));
97f8c67f9   Rishav Singla   ui select impplem...
13
          $scope.selected = [];
07328f442   Rishav Singla   new code added fo...
14
15
          $scope.jetShow = [];
          $scope.marginShow = [];
bfbbd8668   Kuldeep Arora   UI service
16
          $scope.compId = $stateParams.id;
07328f442   Rishav Singla   new code added fo...
17
18
          $scope.jetShow[0] = true;
          $scope.marginShow[0] = true;
5983d987a   Kuldeep Arora   jetmargin api
19
          $scope.dispatchOrder = {};
676250262   Kuldeep Arora   enhancement fuel ...
20
21
22
23
          $scope.dispatchOrder.fuelOrderList = [];
          $scope.statusFilterOptions = [];
          $scope.companyList = {};
          $scope.statusFilterOptions.push({
5983d987a   Kuldeep Arora   jetmargin api
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
                  'id': '',
                  'title': 'Show All'
              }, {
                  'id': 'pending',
                  'title': 'Pending'
              }, {
                  'id': 'invoiced',
                  'title': 'Invoiced'
              }, {
                  'id': 'paid',
                  'title': 'Paid'
              }, {
                  'id': 'cancelled',
                  'title': 'Cancelled'
              }, {
                  'id': 'archived',
                  'title': 'Archived'
676250262   Kuldeep Arora   enhancement fuel ...
41
              }
5983d987a   Kuldeep Arora   jetmargin api
42
43
  
          );
9d840540f   Anchit Jindal   fixed bugs and ne...
44
45
46
          $scope.order = {};
          $scope.order.companyName = '';
      	$scope.order.upliftDate = '';
5983d987a   Kuldeep Arora   jetmargin api
47
48
49
50
51
          /*Get AllCompany api is used from CustomersService*/
          getAllCompanies();
  
          function getAllCompanies() {
              CustomersService.getAllCompanies().then(function(result) {
40c8c308c   Kuldeep Arora   omit css
52
                 //console.log('log', result[2].id);
5983d987a   Kuldeep Arora   jetmargin api
53
                  $scope.companyList = result;
40c8c308c   Kuldeep Arora   omit css
54

5983d987a   Kuldeep Arora   jetmargin api
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
                  for (var i = 0; i < $scope.companyList.length; i++) {
                      if ($scope.companyList[i].companyContact != null) {
                          if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) {
                              $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber;
                          }
                      }
                      if ($scope.companyList[i].primaryContact != null) {
                          if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) {
                              $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName;
                          }
                      }
                      if ($scope.companyList[i].margin != null) {
                          if ($scope.companyList[i].margin.marginName != null) {
                              $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id;
                          }
                      }
                  }
                  $scope.displayCompanyList = new NgTableParams({
                      page: 1,
                      count: 10,
                  }, {
                      data: $scope.companyList
                  });
                  $scope.showLoader = false;
              })
          }
676250262   Kuldeep Arora   enhancement fuel ...
81

3a9f4472b   Rishav   Implement contact...
82

7152ff131   Rishav   model handle
83
84
85
86
87
          $(document).ready(function() {
              $("#reset").click(function() {
                  $("input").val("");
              });
          });
5983d987a   Kuldeep Arora   jetmargin api
88
89
90
91
92
93
94
95
96
97
98
99
          $scope.values = [{
                  'id': 1,
                  'first': 'Tenant/Base Customer'
              },
              {
                  'id': 2,
                  'first': 'FuelerLinx Customer'
              },
              {
                  'id': 3,
                  'first': 'CAA Member'
              }
97f8c67f9   Rishav Singla   ui select impplem...
100
          ];
bfbbd8668   Kuldeep Arora   UI service
101
          
5983d987a   Kuldeep Arora   jetmargin api
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
          $scope.changeValue = function(selected) {
              $scope.showUpdateBtn = true;
              // console.log("data to be true", selected);
              for (var i = 0; i < selected.length; i++) {
                  //  console.log(selected[i])
                  if (selected[i] == 'Tenant/Base Customer') {
                      $scope.companyData.baseTenant = true;
                  } else {
                      $scope.companyData.baseTenant = false;
                  }
                  if (selected[i] == 'FuelerLinx Customer') {
                      $scope.companyData.fuelerlinxCustomer = true;
                  } else {
                      $scope.companyData.fuelerlinxCustomer = false;
                  }
97f8c67f9   Rishav Singla   ui select impplem...
117

5983d987a   Kuldeep Arora   jetmargin api
118
119
120
121
122
123
124
                  if (selected[i] == 'CAA Member') {
                      $scope.companyData.contractFuelVendor = true;
                  } else {
                      $scope.companyData.contractFuelVendor = false;
                  }
  
                  // console.log($scope.companyData)
97f8c67f9   Rishav Singla   ui select impplem...
125

5983d987a   Kuldeep Arora   jetmargin api
126
              }
97f8c67f9   Rishav Singla   ui select impplem...
127
128
  
          }
3a9f4472b   Rishav   Implement contact...
129

48ed0c7bb   Rishav   update company co...
130
          var value = "";
55e075d7e   Rishav   add contact, add ...
131
          var companyId = $stateParams.id;
bfbbd8668   Kuldeep Arora   UI service
132
          
a9a8f570d   Anchit Jindal   new desing implem...
133
134
135
          $scope.companyData = {};
          $scope.multipleMsg = false;
          $scope.companyData.masterMargin = "";
a9aef0b1c   Anchit Jindal   new changes imple...
136
          $scope.isGlobal = false;
0f34b8798   Anchit Jindal   desing and implem...
137
          $scope.fboPreffered = false;
e9a2edf03   Rishav   update custom field
138
          getCompanyDetail();
5983d987a   Kuldeep Arora   jetmargin api
139
140
141
142
143
144
  
          function getCompanyDetail() {
              $scope.showLoader = true;
              ViewCompanyService.getCompany(companyId).then(function(result) {
                  $scope.companyData = result;
                  $scope.isGlobal = result.global;
0f34b8798   Anchit Jindal   desing and implem...
145
                  $scope.fboPreffered = result.fboPreferred;
5983d987a   Kuldeep Arora   jetmargin api
146
147
148
149
150
151
152
153
154
                  if (result.global == true) {
                      $scope.companyData.global = true;
                  }
                  if (result.margin != null) {
                      $scope.companyData.masterMargin = result.margin.id;
                  }
                  if (result.marginAVGAS != null) {
                      $scope.companyData.avgasMargin = result.marginAVGAS.id;
                  }
97f8c67f9   Rishav Singla   ui select impplem...
155

97f8c67f9   Rishav Singla   ui select impplem...
156

5983d987a   Kuldeep Arora   jetmargin api
157
                  if ($scope.companyData.baseTenant) {
97f8c67f9   Rishav Singla   ui select impplem...
158

5983d987a   Kuldeep Arora   jetmargin api
159
160
161
162
                      $scope.selected.push({
                          'first': 'Tenant/Base Customer'
                      })
                      // console.log("$scope.selected",$scope.selected)
97f8c67f9   Rishav Singla   ui select impplem...
163

5983d987a   Kuldeep Arora   jetmargin api
164
                  }
97f8c67f9   Rishav Singla   ui select impplem...
165

5983d987a   Kuldeep Arora   jetmargin api
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
                  if ($scope.companyData.fuelerlinxCustomer) {
                      $scope.selected.push({
                          'first': 'FuelerLinx Customer'
                      })
                      // console.log("$scope.selected",$scope.selected)
                  }
  
                  if ($scope.companyData.contractFuelVendor) {
                      $scope.selected.push({
                          'first': 'CAA Member'
                      })
                      // console.log("$scope.selected",$scope.selected)
                  }
  
                  // console.log("$scope.companyData",$scope.companyData)
                  getAircraftList();
9d840540f   Anchit Jindal   fixed bugs and ne...
182
183
                  $scope.order.companyName = $scope.companyData.companyName;
                  $scope.getAircraft(result.companyName);
5983d987a   Kuldeep Arora   jetmargin api
184
185
                  $scope.showLoader = false;
              })
e9a2edf03   Rishav   update custom field
186
          }
55e075d7e   Rishav   add contact, add ...
187

5983d987a   Kuldeep Arora   jetmargin api
188
189
  
          $scope.changeCompanyStatus = function() {
da24c95c8   Rishav Singla   confirmation mess...
190
              $('#delete3').css('display', 'block');
5983d987a   Kuldeep Arora   jetmargin api
191
192
193
194
              if ($scope.companyData.activate == true) {
                  $scope.statusMessage = 'Please confirm! Are you sure you want to ACTIVATE this company?'
              } else {
                  $scope.statusMessage = 'Please confirm! Are you sure you want to DEACTIVATE this company?'
da24c95c8   Rishav Singla   confirmation mess...
195
196
              }
          }
5983d987a   Kuldeep Arora   jetmargin api
197
198
          $scope.companyStatus = function() {
              $scope.showLoader = true;
3a9f4472b   Rishav   Implement contact...
199
200
              var statusData = "status=" + $scope.companyData.activate;
              ViewCompanyService.changeStatus(companyId, statusData).then(function(result) {
5983d987a   Kuldeep Arora   jetmargin api
201
202
203
204
205
206
207
                  if (result.success) {
                      $('#delete3').css('display', 'none');
                      toastr.success('' + result.success + '', {
                          closeButton: true
                      })
                      getContactList();
                  }
3a9f4472b   Rishav   Implement contact...
208
              })
05bfa28a2   Mr. Hot Foods   remove save butto...
209
              $scope.showLoader = false;
c555af312   Rishav   price email, comp...
210
          }
3a9f4472b   Rishav   Implement contact...
211

5983d987a   Kuldeep Arora   jetmargin api
212
213
  
          $scope.cancelStatus = function() {
da24c95c8   Rishav Singla   confirmation mess...
214
              $('#delete3').css('display', 'none');
5983d987a   Kuldeep Arora   jetmargin api
215
              $scope.companyData.activate = !$scope.companyData.activate;
da24c95c8   Rishav Singla   confirmation mess...
216
          }
5983d987a   Kuldeep Arora   jetmargin api
217

48ed0c7bb   Rishav   update company co...
218
          getContactList();
5983d987a   Kuldeep Arora   jetmargin api
219
220
221
222
223
  
          function getContactList() {
              ViewCompanyService.getContact(companyId).then(function(result) {
                  $scope.companyContactList = result;
              })
48ed0c7bb   Rishav   update company co...
224
          }
a9a8f570d   Anchit Jindal   new desing implem...
225
          $scope.aircraftmargins = [];
5983d987a   Kuldeep Arora   jetmargin api
226

bcd6c1025   Kuldeep Arora   aircraft display-...
227
228
          $scope.abc = false;
          $scope.xyz = false;
5983d987a   Kuldeep Arora   jetmargin api
229
230
          function getAircraftList() {
              ViewCompanyService.getAircraft(companyId).then(function(result) {
bcd6c1025   Kuldeep Arora   aircraft display-...
231
                 
5983d987a   Kuldeep Arora   jetmargin api
232
233
234
235
236
237
                  $scope.contactAircraftList = result;
                  for (var i = 0; i < $scope.contactAircraftList.length; i++) {
                      if ($scope.contactAircraftList[i].aircraftsMargin != null) {
                          $scope.aircraftmargins.push({
                              'id': $scope.contactAircraftList[i].aircraftsMargin.id
                          })
cca8fa318   Kuldeep Arora   aircraft display ...
238
239
                          $scope.contactAircraftList[i].fuelType = "Jet-A";
                          $scope.contactAircraftList[i].marginValue = result[i].aircraftsMargin.marginValue;
dadb46117   Kuldeep Arora   color code for va...
240
                          $scope.abc = true;
bcd6c1025   Kuldeep Arora   aircraft display-...
241
242
243
                          
                      }else{
                          $scope.contactAircraftList[i].fuelType = "100LL";
a858eca3e   Kuldeep Arora   css
244
                          if (result[i].aircraftsAVGASMargin != null) {
cca8fa318   Kuldeep Arora   aircraft display ...
245
                          $scope.contactAircraftList[i].marginValue = result[i].aircraftsAVGASMargin.marginValue;
dadb46117   Kuldeep Arora   color code for va...
246
                          $scope.xyz = true;
a858eca3e   Kuldeep Arora   css
247
248
                              
                          }
5983d987a   Kuldeep Arora   jetmargin api
249
                      }
bcd6c1025   Kuldeep Arora   aircraft display-...
250

5983d987a   Kuldeep Arora   jetmargin api
251
252
253
254
255
256
257
258
259
                  }
                  if ($scope.aircraftmargins.length > 0) {
                      for (var i = 0; i < $scope.aircraftmargins.length; i++) {
                          if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) {
                              $scope.multiple = true;
                              $scope.multipleMsg = true;
                              if ($scope.multiple) {
                                  $scope.companyData.masterMargin = "multiple";
                              }
a9a8f570d   Anchit Jindal   new desing implem...
260
                          }
5983d987a   Kuldeep Arora   jetmargin api
261
                      }
a9a8f570d   Anchit Jindal   new desing implem...
262
                  }
5983d987a   Kuldeep Arora   jetmargin api
263
              })
b1f6160d4   Rishav   add contact and a...
264
          }
b1f6160d4   Rishav   add contact and a...
265

5983d987a   Kuldeep Arora   jetmargin api
266

55e075d7e   Rishav   add contact, add ...
267
268
          $scope.contactData = {};
          $scope.contactData.contactList = [];
5983d987a   Kuldeep Arora   jetmargin api
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
          $scope.addContact = function() {
              $scope.showLoader = true;
              $scope.data.companyId = companyId;
              $scope.contactData.contactList.push($scope.data);
              ViewCompanyService.addContact($scope.contactData).then(function(result) {
                  //console.log("data==",$scope.contactData)
                  // console.log(result)
                  if (result.status == 200) {
  
                      $('#contact-modal-3').modal('hide');
                      $scope.primayData.id = result.data;
                      $scope.data = {};
                      $scope.sendPrimaryContact();
                      getContactList();
                      $scope.contactData.contactList = [];
                      $scope.data.email = '';
5983d987a   Kuldeep Arora   jetmargin api
285
                      toastr.success('Created Successfully', {
cf43d578a   Kuldeep Arora   delete company up...
286
                          closeButton: true
5983d987a   Kuldeep Arora   jetmargin api
287
288
289
290
291
292
293
294
                      })
                  } else {
                      toastr.error('' + result.statusText + '', {
                          closeButton: true
                      })
                  }
              })
              $scope.showLoader = false;
55e075d7e   Rishav   add contact, add ...
295
          }
feacde5ff   Rishav   setup acuefuel in...
296

5983d987a   Kuldeep Arora   jetmargin api
297
298
299
300
301
302
          getData();
  
          function getData() {
              $scope.showLoader = true;
              CustomersService.getAircraftMake().then(function(result) {
                  $scope.aircraftMakeList = result;
40c8c308c   Kuldeep Arora   omit css
303
                 // console.log("make",result)
5983d987a   Kuldeep Arora   jetmargin api
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
              })
              $scope.showLoader = false;
          }
  
          $scope.clearAircrafts = function() {
              $scope.aircraftDetails = [];
              $scope.aircraftDetails = [{
                  'tail': '',
                  'make': '',
                  'model': '',
                  'sizeId': '',
                  'marginId': '',
                  'avgasMarginId': ''
              }];
          }
  
          $scope.addNew = function() {
              $scope.aircraftDetails.push({
                  'tail': '',
                  'make': '',
                  'model': '',
                  'sizeId': '',
                  'marginId': '',
                  'avgasMarginId': ''
a4884cfe7   Rishav   add aircraft issu...
328
              });
5983d987a   Kuldeep Arora   jetmargin api
329
330
331
332
333
334
              //  console.log($scope.aircraftDetails)
          };
  
          $scope.getModal = function(makeId, index) {
              $scope.showLoader = true;
              $scope.aircraft.make = makeId;
5983d987a   Kuldeep Arora   jetmargin api
335
              CustomersService.getModal($scope.aircraft.make).then(function(result) {
33a64416f   Anchit Jindal   mbug fixes
336
337
338
339
                  $scope.showLoader = false;
                  $scope.aircraftDetails[index].aircraftModalList = result;
                  //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0];
              })
b1f6160d4   Rishav   add contact and a...
340
          }
33a64416f   Anchit Jindal   mbug fixes
341
          
bfbbd8668   Kuldeep Arora   UI service
342
          $scope.selectedOption = '';
5983d987a   Kuldeep Arora   jetmargin api
343
344
          $scope.getSize = function(model, index) {
              $scope.showLoader = true;
33a64416f   Anchit Jindal   mbug fixes
345
              $scope.aircraft.model = model;
5983d987a   Kuldeep Arora   jetmargin api
346
347
348
              CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) {
                  $scope.showLoader = false;
                  $scope.aircraftDetails[index].aircraftSizeList = result;
0a364e561   Kuldeep Arora   minor
349
                  $scope.getFuelType($scope.aircraftDetails[index].aircraftSizeList[0].aircraftSize.id,index);
88abaa681   Kuldeep Arora   size auto-populat...
350
                  
6367e69ba   Kuldeep Arora   minor
351
                  
5983d987a   Kuldeep Arora   jetmargin api
352
353
              })
          }
33a64416f   Anchit Jindal   mbug fixes
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
          
          $scope.getFuelType = function(size, index) {
          	$scope.showLoader = true;
          	var data = "model="+$scope.aircraft.model+"&make="+$scope.aircraft.make+"&sizeId="+size;
          	ViewCompanyService.checkFuelType(data).then(function(result){
                $scope.showLoader = false;
                if (result.type == "JetA") {
                    $scope.jetShow[index] = false;
                    $scope.marginShow[index] = true;
                } else if (result.type == "Avgas")   {
                    $scope.jetShow[index] = true;
                    $scope.marginShow[index] = false;
                }else {
                    $scope.jetShow[index] = true;
                    $scope.marginShow[index] = true;
                }
          	})
          }
5983d987a   Kuldeep Arora   jetmargin api
372
373
  
          $scope.aircraftListData = {};
359303f53   Kuldeep Arora   Adding company/ai...
374
375
376
377
378
          $scope.addData = [];
          $scope.tailArray = [];
          function check(array){
              return (new Set(array)).size !== array.length;
          }
5983d987a   Kuldeep Arora   jetmargin api
379
          $scope.saveCompanyData = function() {
359303f53   Kuldeep Arora   Adding company/ai...
380
              $scope.tailArray = [];
2075411ed   Kuldeep Arora   create fuel order...
381
                  for (var i = 0; i < $scope.aircraftDetails.length; i++) {
2075411ed   Kuldeep Arora   create fuel order...
382
383
384
385
386
387
388
389
                      $scope.addData.push({
                          'tail': $scope.aircraftDetails[i].tail,
                          'make': $scope.aircraftDetails[i].make,
                          'model': $scope.aircraftDetails[i].model,
                          'sizeId': $scope.aircraftDetails[i].sizeId,
                          'marginId': $scope.aircraftDetails[i].marginId,
                          'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId
                      });
359303f53   Kuldeep Arora   Adding company/ai...
390
391
                      $scope.tailArray.push($scope.aircraftDetails[i].tail);
                  }
359303f53   Kuldeep Arora   Adding company/ai...
392
393
394
395
396
397
                  if (check($scope.tailArray)) {
                      toastr.error('Duplicate Tail Added.', {
                                  closeButton: true
                              })
                  }else{
                      $scope.aircraftListData.aircraftList = $scope.addData;
e443a586b   Kuldeep Arora   aircraftslist
398
                      $scope.aircraftListData.accountId = companyId;  
359303f53   Kuldeep Arora   Adding company/ai...
399
400
401
402
403
                      CustomersService.addAircraft($scope.aircraftListData).then(function(result) {
                          if (result != null && result.success) {
                              toastr.success('' + result.success + '', {
                                  closeButton: true
                              })
6367e69ba   Kuldeep Arora   minor
404
405
406
                              $scope.addData= [];
                              $scope.tailArray = [];
                              $scope.aircraftListData={};
359303f53   Kuldeep Arora   Adding company/ai...
407
408
                              $('#aircraft-modal-3').css('display', 'none');
                              $('.modal-backdrop').css('display', 'none');
8f525d21f   Kuldeep Arora   modalbox fixed
409
410
                              $('#aircraft-modal-3').modal('hide');
                              $('.modal-backdrop').modal('hide');
359303f53   Kuldeep Arora   Adding company/ai...
411
                              getAircraftList();
8f525d21f   Kuldeep Arora   modalbox fixed
412

359303f53   Kuldeep Arora   Adding company/ai...
413
                          } else {
8f525d21f   Kuldeep Arora   modalbox fixed
414
415
                              $('#aircraft-modal-3').css('display', 'none');
                              $('.modal-backdrop').css('display', 'none');
359303f53   Kuldeep Arora   Adding company/ai...
416
417
418
419
420
                              toastr.error('' + result.statusText + '', {
                                  closeButton: true
                              })
                          }
                      });
5983d987a   Kuldeep Arora   jetmargin api
421
                  }
2075411ed   Kuldeep Arora   create fuel order...
422
                  
5983d987a   Kuldeep Arora   jetmargin api
423
          }
2075411ed   Kuldeep Arora   create fuel order...
424

5983d987a   Kuldeep Arora   jetmargin api
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
          $scope.showNoteData = true;
          $scope.showCompanyName = true;
          $scope.showAddress = true;
          $scope.showNote = function() {
              $scope.showNoteData = false;
              $scope.showUpdateBtn = true;
          }
  
          $scope.company = function() {
              $scope.showCompanyName = false;
              $scope.showUpdateBtn = true;
          }
  
          $scope.base = function() {
              $scope.showUpdateBtn = true;
          }
  
          $scope.addressChange = function() {
              $scope.showAddress = false;
              $scope.showUpdateBtn = true;
          }
  
          $scope.editData = function(inputName) {
              //console.log($scope.companyData)
              $scope.showLoader = true;
              /*if(inputName == 'showNoteData'){
                $scope.showNoteData = true;
              }else if(inputName == 'showCompanyName'){
                $scope.showCompanyName = true;
              }else if(inputName == 'showAddress'){
                $scope.showAddress = true;              
              }*/
a4884cfe7   Rishav   add aircraft issu...
457
              $scope.showNoteData = true;
a4884cfe7   Rishav   add aircraft issu...
458
              $scope.showCompanyName = true;
5983d987a   Kuldeep Arora   jetmargin api
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
              $scope.showAddress = true;
  
              var companyData = "companyName=" + $scope.companyData.companyName + "&masterMargin=" + $scope.companyData.masterMargin + "&avgasMargin=" + $scope.companyData.avgasMargin +
                  "&addressOne=" + $scope.companyData.addressOne + "&addressTwo=" + $scope.companyData.addressTwo + "&city=" + $scope.companyData.city + "&state=" +
                  $scope.companyData.state + "&country=" + $scope.companyData.country + "&zipcode=" + $scope.companyData.zipcode + "&internalNote=" +
                  $scope.companyData.internalNote + "&certificateType=" + $scope.companyData.certificateType + "&baseTenant=" + $scope.companyData.baseTenant +
                  "&fuelerlinxCustomer=" + $scope.companyData.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.companyData.contractFuelVendor +
                  "&activate=" + $scope.companyData.activate + "&baseIcao=" + $scope.companyData.baseIcao + "&companyId=" + companyId + "&global=" + $scope.companyData.global;
  
              ViewCompanyService.updateCompany(companyData).then(function(result) {
                  if (result != null && result.success) {
                      toastr.success('' + result.success + '', {
                          closeButton: true
                      })
                      $scope.showUpdateBtn = false;
                      getCompanyDetail();
                  } else {
9d840540f   Anchit Jindal   fixed bugs and ne...
476
                      toastr.error('Error Updating Company', {
5983d987a   Kuldeep Arora   jetmargin api
477
478
479
480
481
482
483
                          closeButton: true
                      })
                      $scope.showUpdateBtn = true;
                  }
                  $scope.showLoader = false;
              })
          }
9d840540f   Anchit Jindal   fixed bugs and ne...
484
          $scope.cancelUpdateData = function() {
5983d987a   Kuldeep Arora   jetmargin api
485
486
487
488
489
490
491
              $scope.showNoteData = true;
              $scope.showCompanyName = true;
              $scope.showAddress = true;
              $scope.showUpdateBtn = false;
          }
  
          $scope.sendMail = function() {
9d840540f   Anchit Jindal   fixed bugs and ne...
492
          	$scope.showLoader = true;
5983d987a   Kuldeep Arora   jetmargin api
493
494
495
496
497
498
499
              $('#confirm1').css('display', 'none');
              ViewCompanyService.sendMail(companyId).then(function(result) {
                  if (result != null && result.success) {
                      toastr.success('' + result.success + '', {
                          closeButton: true
                      })
                  } else {
9d840540f   Anchit Jindal   fixed bugs and ne...
500
                      toastr.error('Error Sending Email', {
5983d987a   Kuldeep Arora   jetmargin api
501
502
503
                          closeButton: true
                      })
                  }
9d840540f   Anchit Jindal   fixed bugs and ne...
504
                  $scope.showLoader = false;
5983d987a   Kuldeep Arora   jetmargin api
505
506
507
508
509
510
              })
          }
  
          $scope.openConfirmMail = function() {
              $('#confirm1').css('display', 'block');
          }
b1f6160d4   Rishav   add contact and a...
511

48ed0c7bb   Rishav   update company co...
512

5983d987a   Kuldeep Arora   jetmargin api
513
514
515
          $scope.cancelAndCloseConfirm = function() {
              $('#confirm1').css('display', 'none');
          }
b1f6160d4   Rishav   add contact and a...
516

a4884cfe7   Rishav   add aircraft issu...
517
          $scope.primaryContact = false;
5983d987a   Kuldeep Arora   jetmargin api
518
519
520
521
522
523
524
525
526
527
528
529
530
531
          $scope.cancelPrimaryContact = function() {
              $('#primaryContact').css('display', 'none');
              $scope.primaryContact = false;
          }
  
          $scope.checkPrimaryContact = function() {
              if ($scope.primaryContact == true) {
                  $scope.primaryContact = true;
                  ViewCompanyService.checkPrimaryContact(companyId).then(function(result) {
                      //console.log(result)
                      if (result.status == 422) {
                          $('#primaryContact').css('display', 'block');
                      }
                  })
a4884cfe7   Rishav   add aircraft issu...
532
              }
5983d987a   Kuldeep Arora   jetmargin api
533
534
535
536
537
538
539
540
541
542
          }
  
          $scope.sendPrimaryContact = function() {
              $('#primaryContact').css('display', 'none');
              if ($scope.primayData.id != null || $scope.primayData.id != undefined) {
                  var priamryContactData = "companyContactId=" + $scope.primayData.id + "&primary=" + $scope.primaryContact;
  
                  ViewCompanyService.addPrimaryContact(priamryContactData).then(function(result) {
                      // console.log(result)
                  })
8670c5905   Jaideep Singh   new changes
543
              }
8670c5905   Jaideep Singh   new changes
544
          }
5983d987a   Kuldeep Arora   jetmargin api
545
          $scope.updateData = ""
9d840540f   Anchit Jindal   fixed bugs and ne...
546
          $scope.showUpdateContact = function(data, value) {
5983d987a   Kuldeep Arora   jetmargin api
547
548
              $('#updateContact').css('display', 'block');
              $scope.updateData = data;
9d840540f   Anchit Jindal   fixed bugs and ne...
549
550
551
552
553
554
555
556
557
558
559
              // console.log($scope.updateData)
              if ($scope.updateData.email == null) {
                  $scope.updateData.content = data.contactNumber;
              } else {
                  $scope.updateData.content = data.email;
              }
          }
          
          $scope.showUpdateEmail = function(data, value) {
              $('#updateEmail').css('display', 'block');
              $scope.updateData = data;
5983d987a   Kuldeep Arora   jetmargin api
560
561
562
563
564
565
566
              // console.log($scope.updateData)
              if ($scope.updateData.email == null) {
                  $scope.updateData.content = data.contactNumber;
              } else {
                  $scope.updateData.content = data.email;
              }
          }
9d840540f   Anchit Jindal   fixed bugs and ne...
567
          $scope.acceptUpdateField = function(newContactName) {
5983d987a   Kuldeep Arora   jetmargin api
568
569
570
              // console.log($scope.updateData)
              if ($scope.updateData.content == undefined) {
                  toastr.error('Please add some content', {
cdf775224   Anchit Jindal   fixed company and...
571
572
                      closeButton: true
                  })
5983d987a   Kuldeep Arora   jetmargin api
573
574
575
576
577
578
579
580
581
              } else {
                  if (newContactName == 'phone') {
                      var updateCustomData = "companyId=" + companyId + "&contactNumber=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id +
                          "&title=" + $scope.updateData.title;
                  } else {
                      var updateCustomData = "companyId=" + companyId + "&email=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id +
                          "&title=" + $scope.updateData.title;
                  }
                  ViewCompanyService.updateCustomField(updateCustomData).then(function(result) {
5983d987a   Kuldeep Arora   jetmargin api
582
583
                      if (result != null && result.success) {
                          $('#updateContact').css('display', 'none');
9d840540f   Anchit Jindal   fixed bugs and ne...
584
                          $('#updateEmail').css('display', 'none');
5983d987a   Kuldeep Arora   jetmargin api
585
586
587
                          getCompanyDetail();
                      }
                  })
cdf775224   Anchit Jindal   fixed company and...
588
              }
cdf775224   Anchit Jindal   fixed company and...
589
          }
9d840540f   Anchit Jindal   fixed bugs and ne...
590
591
592
593
594
595
596
597
598
599
600
          
          $scope.deleteContent = function(data){
          	ViewCompanyService.deleteCustomContact(data.id).then(function(result) {
                  if (result != null && result.success) {
                  	toastr.success('' + result.success + '', {
                          closeButton: true
                      })
                      getCompanyDetail();
                  }
              })
          }
07328f442   Rishav Singla   new code added fo...
601

5983d987a   Kuldeep Arora   jetmargin api
602
603
          $scope.cancelUpdateField = function() {
              $('#updateContact').css('display', 'none');
9d840540f   Anchit Jindal   fixed bugs and ne...
604
              $('#updateEmail').css('display', 'none');
5983d987a   Kuldeep Arora   jetmargin api
605
606
607
608
609
610
          }
  
          $scope.showEditTier2 = function(number) {
              // console.log(number)
              $scope.contactNumber = number;
          }
07328f442   Rishav Singla   new code added fo...
611

5983d987a   Kuldeep Arora   jetmargin api
612

9d840540f   Anchit Jindal   fixed bugs and ne...
613
          $scope.addCustomPhone = function(value) {
5983d987a   Kuldeep Arora   jetmargin api
614
615
              //console.log(value)
              if (value != null) {
9d840540f   Anchit Jindal   fixed bugs and ne...
616
617
618
619
620
621
622
623
624
                  $('#customFieldPhone').css('display', 'block');
              }
              $scope.custom = {};
          }
          
          $scope.addCustomEmail = function(value) {
              //console.log(value)
              if (value != null) {
                  $('#customFieldEmail').css('display', 'block');
07328f442   Rishav Singla   new code added fo...
625
              }
5983d987a   Kuldeep Arora   jetmargin api
626
              $scope.custom = {};
07328f442   Rishav Singla   new code added fo...
627
          }
cf43d578a   Kuldeep Arora   delete company up...
628

5983d987a   Kuldeep Arora   jetmargin api
629
          $scope.cancelCustomField = function() {
9d840540f   Anchit Jindal   fixed bugs and ne...
630
631
              $('#customFieldEmail').css('display', 'none');
              $('#customFieldPhone').css('display', 'none');
5983d987a   Kuldeep Arora   jetmargin api
632
          }
676250262   Kuldeep Arora   enhancement fuel ...
633

9d840540f   Anchit Jindal   fixed bugs and ne...
634
          $scope.acceptCustomField = function(contactName) {
5983d987a   Kuldeep Arora   jetmargin api
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
              if ($scope.custom.content == undefined) {
                  toastr.error('Please add some content', {
                      closeButton: true
                  })
              } else {
                  if (contactName == 'phone') {
                      var customData = "companyId=" + companyId + "&contactNumber=" + $scope.custom.content +
                          "&title=" + $scope.custom.title;
                  } else {
                      var customData = "companyId=" + companyId + "&email=" + $scope.custom.content +
                          "&title=" + $scope.custom.title;
                  }
                  // console.log(customData.email)
                  ViewCompanyService.addCustomField(customData).then(function(result) {
                      // console.log(result)
                      if (result != null && result.success) {
9d840540f   Anchit Jindal   fixed bugs and ne...
651
652
653
                          $('#customFieldEmail').css('display', 'none');
                          $('#customFieldPhone').css('display', 'none');
                          $scope.custom = {};
5983d987a   Kuldeep Arora   jetmargin api
654
655
656
657
658
                          getCompanyDetail();
                      }
                  })
              }
          }
676250262   Kuldeep Arora   enhancement fuel ...
659

64b3dc0e3   Kuldeep Arora   omit vendor and c...
660
          /*  omit strike out*/
5983d987a   Kuldeep Arora   jetmargin api
661
662
          updateFuelManagerService.getFuelPricingNew().then(function(result) {
              $scope.fuelPricing = result;
169fc146e   Kuldeep Arora   final omit ui
663
              //console.log("==fuel pricing==",result)
bfbbd8668   Kuldeep Arora   UI service
664
665
666
              $scope.omitData;
              ViewCompanyService.getOmitCompany($scope.compId).then(function(result){
                  $scope.omitData = result;
169fc146e   Kuldeep Arora   final omit ui
667
                 // console.log("omit data===", $scope.omitData);
64b3dc0e3   Kuldeep Arora   omit vendor and c...
668
669
670
671
                  for(var i = 0 ; i< $scope.fuelPricing.length; i++){
                      for(var j = 0; j<$scope.omitData.length; j++){
                          if($scope.omitData[j].marginId == $scope.fuelPricing[i].fuelPricing.id){
                              $scope.fuelPricing[i].fuelPricing.omit = $scope.omitData[j].omit;
169fc146e   Kuldeep Arora   final omit ui
672
                            //  console.log("fuel.pricing.omit",$scope.fuelPricing[i].fuelPricing.omit)
64b3dc0e3   Kuldeep Arora   omit vendor and c...
673
674
675
                      }
                          }
                  }
bfbbd8668   Kuldeep Arora   UI service
676
              })
64b3dc0e3   Kuldeep Arora   omit vendor and c...
677
             // console.log("$scope.fuelPricing",$scope.fuelPricing)
5983d987a   Kuldeep Arora   jetmargin api
678
              for (var i = 0; i < $scope.fuelPricing.length; i++) {
64b3dc0e3   Kuldeep Arora   omit vendor and c...
679
                //  console.log('$scope.fuelPricing[i].fuelPricing', $scope.fuelPricing[i].fuelPricing);
dadb46117   Kuldeep Arora   color code for va...
680
                //console.log("fuelid",$scope.fuelPricing[i].fuelPricing.id,"getid",$scope.omitData[j].id)
5983d987a   Kuldeep Arora   jetmargin api
681
682
683
684
685
686
687
688
                  if ($scope.fuelPricing[i].fuelPricing.expirationDate != null) {
                      $scope.fuelPricing[i].fuelPricing.expirationDate = new Date($scope.fuelPricing[i].fuelPricing.expirationDate);
                      var newTime = new Date($scope.fuelPricing[i].fuelPricing.expirationDate);
                      var dmonth = newTime.getUTCMonth() + 1; //months from 1-12
                      var dday = newTime.getUTCDate();
                      var dyear = newTime.getUTCFullYear();
                      $scope.fuelPricing[i].fuelPricing.expirationDate = dmonth + '/' + dday + '/' + dyear;
                  }
bfbbd8668   Kuldeep Arora   UI service
689
690
691
692
693
                  // for (var j = 0; j<$scope.omitData.length; j++) {
                  //     if($scope.fuelPricing[i].fuelPricing.id === $scope.omitData[j].id){
  
                  //     }
                  // }
5983d987a   Kuldeep Arora   jetmargin api
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
              }
          })
  
          var deleteAircraftId = "";
          $scope.deleteAircraft = function(id) {
              $('#delete1').css('display', 'block');
              deleteAircraftId = id;
          }
  
          $scope.aircraftDelete = function() {
              ViewCompanyService.deleteAircraft(deleteAircraftId).then(function(result) {
                  // console.log(result)
                  getAircraftList();
                  getCompanyDetail();
                  $('#delete1').css('display', 'none');
              })
          }
de63dd418   Kuldeep Arora   cancelbutton
711
          $scope.cancelAircraft = function() {
5983d987a   Kuldeep Arora   jetmargin api
712
713
714
715
716
717
718
719
720
721
              $('#delete1').css('display', 'none');
          }
  
          CustomersService.getJetMargin($scope.userProfileId).then(function(result) {
              $scope.jetMarginList = result;
          })
  
          CustomersService.getAvgMargin($scope.userProfileId).then(function(result) {
              $scope.avgsMarginList = result;
          })
676250262   Kuldeep Arora   enhancement fuel ...
722

5983d987a   Kuldeep Arora   jetmargin api
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
          $scope.changePriceEmail = function(id, index) {
              event.stopPropagation();
              var contactId = id;
              var statusData = "status=" + $scope.companyContactList[index].priceEmail;
              ViewcontactService.changePriceEmail(contactId, statusData).then(function(result) {
                  if (result.success) {
                      $('#toogleMail').css('display', 'block');
                      if ($scope.companyContactList[index].priceEmail == true) {
                          $scope.messageText = 'You have enabled price distribution for this contact';
                      } else {
                          $scope.messageText = 'You have disabled price distribution for this contact';
                      }
                  }
              })
          }
  
          $scope.cancelToogle = function() {
              $('#toogleMail').css('display', 'none');
          }
  
          $scope.checkboxStatus = function(value) {
              //  console.log("checkbox",value)
              $scope.showUpdateBtn = true;
          }
  
          $scope.fuelercheckboxStatus = function(value) {
              $('#fuelerchange').css('display', 'block');
              if (value == true) {
                  $scope.statusMessage = 'Please confirm! Enabling FuelerLinx for this customer will enable price distribution web services and disable price emails for the contacts in this company'
              } else {
                  $scope.statusMessage = 'Please confirm! Disabling FuelerLinx for this customer will disable price distribution web services into their FuelerLinx account. If you proceed then remember to enable price emails for the appropriate contacts in this company.'
676250262   Kuldeep Arora   enhancement fuel ...
754
              }
676250262   Kuldeep Arora   enhancement fuel ...
755

5983d987a   Kuldeep Arora   jetmargin api
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
  
          }
  
          $scope.fuelerCancelStatus = function() {
              $('#fuelerchange').css('display', 'none');
              $scope.companyData.fuelerlinxCustomer = !$scope.companyData.fuelerlinxCustomer;
          }
  
          $scope.fuelerAcceptStatus = function() {
              $('#fuelerchange').css('display', 'none');
              $scope.showLoader = true;
              var statusData;
              if ($scope.companyData.fuelerlinxCustomer == false) {
                  statusData = "status=true";
              } else {
                  statusData = "status=false";
              }
              ViewCompanyService.fuelerPricingChange(companyId, statusData).then(function(result) {
                  if (result.success) {
                      $scope.showLoader = false;
  
                      $scope.editData();
                      getContactList();
  
                  }
676250262   Kuldeep Arora   enhancement fuel ...
781
              })
5983d987a   Kuldeep Arora   jetmargin api
782
          }
bcd6c1025   Kuldeep Arora   aircraft display-...
783
      
5983d987a   Kuldeep Arora   jetmargin api
784
785
786
          $scope.updateOmit = function(fuel, omit) {
              $scope.fuelData = {};
              $scope.fuelData.expirationDate = new Date(fuel.expirationDate);
bfbbd8668   Kuldeep Arora   UI service
787
              $scope.fuelData.customMarginId = fuel.id;
5983d987a   Kuldeep Arora   jetmargin api
788
789
790
791
              $scope.fuelData.omit = fuel.omit;
              $scope.fuelData.papMargin = fuel.papMargin;
              $scope.fuelData.papTotal = fuel.papTotal;
              $scope.fuelData.cost = fuel.cost;
bfbbd8668   Kuldeep Arora   UI service
792
              $scope.fuelData.companyId = $scope.compId ;
bfbbd8668   Kuldeep Arora   UI service
793
794
              if($scope.fuelData.omit == true)
              {
bfbbd8668   Kuldeep Arora   UI service
795
                  var customData = "companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId;
20b4aefe7   Kuldeep Arora   viewcompany
796
               //   console.log(".")
bfbbd8668   Kuldeep Arora   UI service
797
798
799
800
801
802
803
804
805
806
807
808
                   ViewCompanyService.omitAddCompanyFuel(customData).then(function(result) {
                      if (result.success) {
                          toastr.success('' + result.success + '', {
                              closeButton: true
                          })
                      } else {
                          toastr.error('' + result.statusText + '', {
                              closeButton: true
                          })
                      }
                  }) 
              }else{
64b3dc0e3   Kuldeep Arora   omit vendor and c...
809
810
                       var data ="companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId;
                  ViewCompanyService.omitDeleteCompanyFuel(data).then(function(result){
bfbbd8668   Kuldeep Arora   UI service
811
812
813
814
815
816
817
818
819
820
821
                          if (result.success) {
                          toastr.success('' + result.success + '', {
                              closeButton: true
                          })
                        } else {
                          toastr.error('' + result.statusText + '', {
                              closeButton: true
                          })
                      }
                  })
              }
5983d987a   Kuldeep Arora   jetmargin api
822
          }
5983d987a   Kuldeep Arora   jetmargin api
823
          /*add a fuel order*/
5983d987a   Kuldeep Arora   jetmargin api
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
          $scope.getOrders = function() {
              fuelOrdersService.getOrders().then(function(result) {
  
                  $scope.orderdata = result;
                  for (var i = 0; i < $scope.orderdata.length; i++) {
                      $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate);
  
                      // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear()
                      var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear()
                      //  str = str.slice(4,16)
                      $scope.orderdata[i].upliftDateString = str
                      // console.log(str);
  
                  }
  
                  $scope.displayFuelOrderList = new NgTableParams({
                      page: 1,
                      count: 10,
                  }, {
                      data: $scope.orderdata
                  });
                  $(document).ready(function() {
                      var myselect = document.getElementsByClassName('colorfulSelectbox');
  
                      for (var i = 0; i < myselect.length; i++) {
                          var colourIndex = $(myselect[i]).prop('selectedIndex');
                          colourIndex = colourIndex + 1;
                          // console.log(colourIndex);
                          var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color');
                          $(myselect[i]).css('background-color', getColor);
                          // console.log('colour', getColor);
                          myselect[i].blur();
                      }
676250262   Kuldeep Arora   enhancement fuel ...
857
                  })
5983d987a   Kuldeep Arora   jetmargin api
858

676250262   Kuldeep Arora   enhancement fuel ...
859
              })
5983d987a   Kuldeep Arora   jetmargin api
860
861
862
          }
  
          $scope.getOrders();
9d840540f   Anchit Jindal   fixed bugs and ne...
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
          
          $scope.tiervalue=function(){
      		$scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak;
      	}
  
      	$scope.setCost = function(cost){
      		if(cost != null) {
      			var obj =JSON.parse(cost);
      			$scope.order.fboCost = obj.cost;
      		}
      	}
  
      	$scope.cancelOrder = function() {
      		$scope.order = {};
      	}
      	
      	$scope.dispatchFuel = function(){
      		$scope.showLoader = true;
      		$scope.order.companyId = $scope.compId;
      		if ($scope.order.upliftDate != '') {
      			var currentDate = new Date();
                  var hours = currentDate.getHours();
                  var min = currentDate.getMinutes();
                  var sec = currentDate.getSeconds();
                  $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec;
      			$scope.order.upliftDate = new Date($scope.order.upliftDate);
      			$scope.order.upliftDate = $scope.order.upliftDate.getTime();
      		}
      		$scope.order.status = 'pending';
      		var obj =JSON.parse($scope.order.priceQuote);
748fc1d4b   Anchit Jindal   minor changes
893
894
895
      		$scope.order.priceQuote = obj.papTotal;
      		$scope.order.fboCost = obj.cost;
      		$scope.order.total = obj.papTotal * $scope.order.volume;
9d840540f   Anchit Jindal   fixed bugs and ne...
896
897
898
899
900
901
902
903
904
905
906
      		var aircraftObj =JSON.parse($scope.order.aircraftName);
      		$scope.order.aircraftName = aircraftObj.tail;
      		$scope.order.make = aircraftObj.make;
      		$scope.order.model = aircraftObj.model;
      		$scope.dispatchOrder.fuelOrderList.push($scope.order);
      		enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
      			$scope.showLoader = false;
      			$scope.order = {};
      			$('#demo-modal-4').css('display', '');
      			toastr.success('Fuel Order Dispatched Successfully', {
                    closeButton: true
5983d987a   Kuldeep Arora   jetmargin api
907
                  })
9d840540f   Anchit Jindal   fixed bugs and ne...
908
909
      		})
      	}
5983d987a   Kuldeep Arora   jetmargin api
910
911
912
913
914
915
916
917
918
919
  
          $scope.addTotal = function(value, valueOf) {
              if (valueOf == 'v') {
                  $scope.order.total = value * $scope.order.invoiced
              } else if (valueOf == 'i') {
                  $scope.order.total = $scope.order.volume * value
              }
          }
  
          $scope.getAircraft = function(company) {
5983d987a   Kuldeep Arora   jetmargin api
920
              $scope.selectedCompanyName = company;
9d840540f   Anchit Jindal   fixed bugs and ne...
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
              
              if ($scope.companyData.margin != null && $scope.companyData.marginAVGAS != null) {
                  fuelOrdersService.getFuelCost($scope.companyData.id).then(function(margins) {
                      $scope.marginList = margins;
                      //console.log('$scope.marginList', $scope.marginList);
                  })
              } else if ($scope.companyData.margin != null || $scope.companyData.marginAVGAS == null) {
                  fuelOrdersService.getATypeFuelPricing($scope.companyData.id).then(function(margins) {
                      $scope.marginList = margins;
                  })
              } else if ($scope.companyData.margin == null || $scope.companyData.marginAVGAS != null) {
                  fuelOrdersService.getVTypeFuelPricing($scope.companyData.id).then(function(margins) {
                      $scope.marginList = margins;
                  })
              }
              
              
          	$scope.selectedCompanyId = $scope.companyData.id;
              $scope.marginId = $scope.companyData.margin.id;
              if ($scope.selectedCompanyId != '') {
                  fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) {
                      $scope.aircraftList = aircraft;
                  })
              }
              if ($scope.marginId != '') {
                  fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) {
                      $scope.tierList = tiers;
                      //              $scope.showLoader = false;
                  })
5983d987a   Kuldeep Arora   jetmargin api
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
              }
  
          }
  
          $scope.setCost = function(cost) {
              //  console.log(cost);
              if (cost != null) {
                  var obj = JSON.parse(cost);
                  // console.log("0bj",obj)
                  $scope.order.fboCost = obj.cost;
              }
  
          }
  
          $scope.sourceList = [{
              source: "Direct Jet-A"
          }, {
              source: "Direct AVGAS 100LL"
          }];
          $scope.cancelData = function() {
676250262   Kuldeep Arora   enhancement fuel ...
970
              $('#demo-modal-4').css('display', '');
5983d987a   Kuldeep Arora   jetmargin api
971
972
973
974
          }
  
          $scope.setFuel = function() {
              $('#demo-modal-4').css('display', 'block');
676250262   Kuldeep Arora   enhancement fuel ...
975

5983d987a   Kuldeep Arora   jetmargin api
976
          }
676250262   Kuldeep Arora   enhancement fuel ...
977

cf43d578a   Kuldeep Arora   delete company up...
978
          /*delete company*/
5983d987a   Kuldeep Arora   jetmargin api
979
980
          var deletecompanyId = "";
          $scope.deleteComp = function(companyDataid) {
cf43d578a   Kuldeep Arora   delete company up...
981
982
983
984
              $('#delete2').css('display', 'block');
              //console.log("asda",companyDataid)
              deletecompanyId = companyDataid;
          }
1d7e82fdd   Anchit Jindal   fixed bug
985
986
987
988
989
990
991
992
993
994
995
996
997
998
          $scope.aircraftIdx = '';
          $scope.checkTail = function(tail, idx){
          	var data = "tail=" + tail + "&id=" + companyId;
          	$scope.aircraftIdx = idx;
          	ViewCompanyService.checkTail(data).then(function(result) {
                  if(result.error) {
                  	$scope.aircraftMessage = result.error;
                  	$scope.openAddAirCraftError();
                  } else if(result.warning) {
                  	$scope.aircraftMessage = result.warning;
                  	$scope.openAddAirCraftWarning();
                  }
              })
          }
cf43d578a   Kuldeep Arora   delete company up...
999

1d7e82fdd   Anchit Jindal   fixed bug
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
          $scope.openAddAirCraftError = function() {
          	$('#addAirCraftError').css('display', 'block');
          }
          
          $scope.openAddAirCraftWarning = function() {
         	 	$('#addAirCraftWarning').css('display', 'block');
          }
          $scope.acceptAirCraftError = function() {
          	$('#addAirCraftWarning').css('display', 'none');
          }
          
          $scope.cancelAirCraftError = function() {
          	$scope.aircraftDetails[$scope.aircraftIdx].tail = '';
          	$('#addAirCraftWarning').css('display', 'none');
          	$('#addAirCraftError').css('display', 'none');
          }
          
5983d987a   Kuldeep Arora   jetmargin api
1017
          $scope.deleteCompanyData = function() {
cf43d578a   Kuldeep Arora   delete company up...
1018
              ViewCompanyService.deleteCompany(deletecompanyId).then(function(result) {
cf43d578a   Kuldeep Arora   delete company up...
1019

5983d987a   Kuldeep Arora   jetmargin api
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
                  $('#delete2').css('display', 'none');
                  if (result.success) {
                      toastr.success('' + result.success + '', {
                          closeButton: true
  
                      })
                  } else {
                      toastr.error('' + result.statusText + '', {
                          closeButton: true
  
                      })
                  }
                  $state.go('app.customers')
              })
          }
          $scope.cancelDelete = function() {
              $('#delete2').css('display', 'none');
          }
cf43d578a   Kuldeep Arora   delete company up...
1038

5983d987a   Kuldeep Arora   jetmargin api
1039
1040
          $scope.editJetMargin = function(aircraftData, type) {
              $scope.showLoader = true;
6c5a99488   Kuldeep Arora   analytics and fue...
1041
              if (type == 'jet') {
cca8fa318   Kuldeep Arora   aircraft display ...
1042
                  
5983d987a   Kuldeep Arora   jetmargin api
1043
                  var aircraftdataMargin = "marginId=" + aircraftData.aircraftsMargin.id + "&type=" + type;
cca8fa318   Kuldeep Arora   aircraft display ...
1044
                  
5983d987a   Kuldeep Arora   jetmargin api
1045
              } else {
5983d987a   Kuldeep Arora   jetmargin api
1046
                  var aircraftdataMargin = "marginId=" + aircraftData.aircraftsAVGASMargin.id + "&type=" + type;
cf43d578a   Kuldeep Arora   delete company up...
1047
              }
5983d987a   Kuldeep Arora   jetmargin api
1048
1049
1050
1051
1052
1053
1054
1055
  
              var id = aircraftData.id;
              ViewCompanyService.updateAircraftMargin(aircraftdataMargin, id).then(function(result) {
                  if (result != null && result.success) {
                      $scope.showLoader = false;
                      toastr.success('' + result.success + '', {
                          closeButton: true
                      })
bcd6c1025   Kuldeep Arora   aircraft display-...
1056
1057
                     // getAircraftWithMarginList();
                     getAircraftList();
5983d987a   Kuldeep Arora   jetmargin api
1058
1059
1060
1061
1062
1063
1064
1065
                  } else {
                      $scope.showLoader = false;
                      toastr.error('' + result.statusText + '', {
                          closeButton: true
                      })
                  }
              })
          }
cca8fa318   Kuldeep Arora   aircraft display ...
1066
1067
  
          /* //not used currently 
5983d987a   Kuldeep Arora   jetmargin api
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
          function getAircraftWithMarginList() {
              ViewCompanyService.getJetAMargin(companyId).then(function(result) {
                  $scope.contactAircraftList = result;
                  for (var i = 0; i < $scope.contactAircraftList.length; i++) {
                      if ($scope.contactAircraftList[i].aircraftsMargin != null) {
                          $scope.aircraftmargins.push({
                              'id': $scope.contactAircraftList[i].aircraftsMargin.id
                          })
                      }
                  }
                  if ($scope.aircraftmargins.length > 0) {
                      for (var i = 0; i < $scope.aircraftmargins.length; i++) {
                          if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) {
                              $scope.multiple = true;
                              $scope.multipleMsg = true;
                              if ($scope.multiple) {
                                  $scope.companyData.masterMargin = "multiple";
                              }
                          }
                      }
                  }
cf43d578a   Kuldeep Arora   delete company up...
1089
              })
cca8fa318   Kuldeep Arora   aircraft display ...
1090
          }*/
40c8c308c   Kuldeep Arora   omit css
1091

40c8c308c   Kuldeep Arora   omit css
1092

5983d987a   Kuldeep Arora   jetmargin api
1093
      }]);