Blame view

app/partials/viewCompany/viewCompany.controller.js 44.4 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
129
130
131
132
133
134
  
          }
  
          // $scope.selected =[
          //   {'id': 1, 'first': 'Tenant/Base Customer'}, 
          //   {'id': 2, 'first': 'FuelerLinx Customer'},
          //   {'id': 3, 'first': 'CAA Member'}
          // ];
d1fe89776   Rishav Singla   view fuel vendor ...
135
136
137
          // CustomersService.getMargin().then(function(result) {
          //   $scope.marginList = result;
          // })
3a9f4472b   Rishav   Implement contact...
138

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

97f8c67f9   Rishav Singla   ui select impplem...
165

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

5983d987a   Kuldeep Arora   jetmargin api
168
169
170
171
                      $scope.selected.push({
                          'first': 'Tenant/Base Customer'
                      })
                      // console.log("$scope.selected",$scope.selected)
97f8c67f9   Rishav Singla   ui select impplem...
172

5983d987a   Kuldeep Arora   jetmargin api
173
                  }
97f8c67f9   Rishav Singla   ui select impplem...
174

5983d987a   Kuldeep Arora   jetmargin api
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
                  if ($scope.companyData.fuelerlinxCustomer) {
                      $scope.selected.push({
                          'first': 'FuelerLinx Customer'
                      })
                      // console.log("$scope.selected",$scope.selected)
                  }
  
                  if ($scope.companyData.contractFuelVendor) {
                      $scope.selected.push({
                          'first': 'CAA Member'
                      })
                      // console.log("$scope.selected",$scope.selected)
                  }
  
                  // console.log("$scope.companyData",$scope.companyData)
                  getAircraftList();
9d840540f   Anchit Jindal   fixed bugs and ne...
191
192
                  $scope.order.companyName = $scope.companyData.companyName;
                  $scope.getAircraft(result.companyName);
5983d987a   Kuldeep Arora   jetmargin api
193
194
                  $scope.showLoader = false;
              })
e9a2edf03   Rishav   update custom field
195
          }
55e075d7e   Rishav   add contact, add ...
196

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

5983d987a   Kuldeep Arora   jetmargin api
221
222
  
          $scope.cancelStatus = function() {
da24c95c8   Rishav Singla   confirmation mess...
223
              $('#delete3').css('display', 'none');
5983d987a   Kuldeep Arora   jetmargin api
224
              $scope.companyData.activate = !$scope.companyData.activate;
da24c95c8   Rishav Singla   confirmation mess...
225
          }
5983d987a   Kuldeep Arora   jetmargin api
226

48ed0c7bb   Rishav   update company co...
227
          getContactList();
5983d987a   Kuldeep Arora   jetmargin api
228
229
230
231
232
  
          function getContactList() {
              ViewCompanyService.getContact(companyId).then(function(result) {
                  $scope.companyContactList = result;
              })
48ed0c7bb   Rishav   update company co...
233
          }
a9a8f570d   Anchit Jindal   new desing implem...
234
          $scope.aircraftmargins = [];
5983d987a   Kuldeep Arora   jetmargin api
235

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

5983d987a   Kuldeep Arora   jetmargin api
257
258
259
260
261
262
263
264
265
                  }
                  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...
266
                          }
5983d987a   Kuldeep Arora   jetmargin api
267
                      }
a9a8f570d   Anchit Jindal   new desing implem...
268
                  }
5983d987a   Kuldeep Arora   jetmargin api
269
              })
b1f6160d4   Rishav   add contact and a...
270
          }
b1f6160d4   Rishav   add contact and a...
271

5983d987a   Kuldeep Arora   jetmargin api
272

55e075d7e   Rishav   add contact, add ...
273
274
          $scope.contactData = {};
          $scope.contactData.contactList = [];
5983d987a   Kuldeep Arora   jetmargin api
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
          $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
291
                      toastr.success('Created Successfully', {
cf43d578a   Kuldeep Arora   delete company up...
292
                          closeButton: true
5983d987a   Kuldeep Arora   jetmargin api
293
294
295
296
297
298
299
300
                      })
                  } else {
                      toastr.error('' + result.statusText + '', {
                          closeButton: true
                      })
                  }
              })
              $scope.showLoader = false;
55e075d7e   Rishav   add contact, add ...
301
          }
feacde5ff   Rishav   setup acuefuel in...
302

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

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

5983d987a   Kuldeep Arora   jetmargin api
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
457
458
459
460
461
462
          $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...
463
              $scope.showNoteData = true;
a4884cfe7   Rishav   add aircraft issu...
464
              $scope.showCompanyName = true;
5983d987a   Kuldeep Arora   jetmargin api
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
              $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...
482
                      toastr.error('Error Updating Company', {
5983d987a   Kuldeep Arora   jetmargin api
483
484
485
486
487
488
489
                          closeButton: true
                      })
                      $scope.showUpdateBtn = true;
                  }
                  $scope.showLoader = false;
              })
          }
9d840540f   Anchit Jindal   fixed bugs and ne...
490
          $scope.cancelUpdateData = function() {
5983d987a   Kuldeep Arora   jetmargin api
491
492
493
494
495
496
497
              $scope.showNoteData = true;
              $scope.showCompanyName = true;
              $scope.showAddress = true;
              $scope.showUpdateBtn = false;
          }
  
          $scope.sendMail = function() {
9d840540f   Anchit Jindal   fixed bugs and ne...
498
          	$scope.showLoader = true;
5983d987a   Kuldeep Arora   jetmargin api
499
500
501
502
503
504
505
              $('#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...
506
                      toastr.error('Error Sending Email', {
5983d987a   Kuldeep Arora   jetmargin api
507
508
509
                          closeButton: true
                      })
                  }
9d840540f   Anchit Jindal   fixed bugs and ne...
510
                  $scope.showLoader = false;
5983d987a   Kuldeep Arora   jetmargin api
511
512
513
514
515
516
              })
          }
  
          $scope.openConfirmMail = function() {
              $('#confirm1').css('display', 'block');
          }
b1f6160d4   Rishav   add contact and a...
517

48ed0c7bb   Rishav   update company co...
518

5983d987a   Kuldeep Arora   jetmargin api
519
520
521
          $scope.cancelAndCloseConfirm = function() {
              $('#confirm1').css('display', 'none');
          }
b1f6160d4   Rishav   add contact and a...
522

a4884cfe7   Rishav   add aircraft issu...
523
          $scope.primaryContact = false;
5983d987a   Kuldeep Arora   jetmargin api
524
525
526
527
528
529
530
531
532
533
534
535
536
537
          $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...
538
              }
5983d987a   Kuldeep Arora   jetmargin api
539
540
541
542
543
544
545
546
547
548
          }
  
          $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
549
              }
8670c5905   Jaideep Singh   new changes
550
          }
5983d987a   Kuldeep Arora   jetmargin api
551
          $scope.updateData = ""
9d840540f   Anchit Jindal   fixed bugs and ne...
552
          $scope.showUpdateContact = function(data, value) {
5983d987a   Kuldeep Arora   jetmargin api
553
554
              $('#updateContact').css('display', 'block');
              $scope.updateData = data;
9d840540f   Anchit Jindal   fixed bugs and ne...
555
556
557
558
559
560
561
562
563
564
565
              // 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
566
567
568
569
570
571
572
              // 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...
573
          $scope.acceptUpdateField = function(newContactName) {
5983d987a   Kuldeep Arora   jetmargin api
574
575
576
              // console.log($scope.updateData)
              if ($scope.updateData.content == undefined) {
                  toastr.error('Please add some content', {
cdf775224   Anchit Jindal   fixed company and...
577
578
                      closeButton: true
                  })
5983d987a   Kuldeep Arora   jetmargin api
579
580
581
582
583
584
585
586
587
              } 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
588
589
                      if (result != null && result.success) {
                          $('#updateContact').css('display', 'none');
9d840540f   Anchit Jindal   fixed bugs and ne...
590
                          $('#updateEmail').css('display', 'none');
5983d987a   Kuldeep Arora   jetmargin api
591
592
593
                          getCompanyDetail();
                      }
                  })
cdf775224   Anchit Jindal   fixed company and...
594
              }
cdf775224   Anchit Jindal   fixed company and...
595
          }
9d840540f   Anchit Jindal   fixed bugs and ne...
596
597
598
599
600
601
602
603
604
605
606
          
          $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...
607

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

5983d987a   Kuldeep Arora   jetmargin api
618

9d840540f   Anchit Jindal   fixed bugs and ne...
619
          $scope.addCustomPhone = function(value) {
5983d987a   Kuldeep Arora   jetmargin api
620
621
              //console.log(value)
              if (value != null) {
9d840540f   Anchit Jindal   fixed bugs and ne...
622
623
624
625
626
627
628
629
630
                  $('#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...
631
              }
5983d987a   Kuldeep Arora   jetmargin api
632
              $scope.custom = {};
07328f442   Rishav Singla   new code added fo...
633
          }
cf43d578a   Kuldeep Arora   delete company up...
634

5983d987a   Kuldeep Arora   jetmargin api
635
          $scope.cancelCustomField = function() {
9d840540f   Anchit Jindal   fixed bugs and ne...
636
637
              $('#customFieldEmail').css('display', 'none');
              $('#customFieldPhone').css('display', 'none');
5983d987a   Kuldeep Arora   jetmargin api
638
          }
676250262   Kuldeep Arora   enhancement fuel ...
639

9d840540f   Anchit Jindal   fixed bugs and ne...
640
          $scope.acceptCustomField = function(contactName) {
5983d987a   Kuldeep Arora   jetmargin api
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
              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...
657
658
659
                          $('#customFieldEmail').css('display', 'none');
                          $('#customFieldPhone').css('display', 'none');
                          $scope.custom = {};
5983d987a   Kuldeep Arora   jetmargin api
660
661
662
663
664
                          getCompanyDetail();
                      }
                  })
              }
          }
676250262   Kuldeep Arora   enhancement fuel ...
665

64b3dc0e3   Kuldeep Arora   omit vendor and c...
666
          /*  omit strike out*/
5983d987a   Kuldeep Arora   jetmargin api
667
668
          updateFuelManagerService.getFuelPricingNew().then(function(result) {
              $scope.fuelPricing = result;
bfbbd8668   Kuldeep Arora   UI service
669
670
671
              $scope.omitData;
              ViewCompanyService.getOmitCompany($scope.compId).then(function(result){
                  $scope.omitData = result;
64b3dc0e3   Kuldeep Arora   omit vendor and c...
672
673
674
675
676
677
678
679
                  //console.log("omit data===", $scope.omitData);
                  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;
                      }
                          }
                  }
bfbbd8668   Kuldeep Arora   UI service
680
              })
64b3dc0e3   Kuldeep Arora   omit vendor and c...
681
             // console.log("$scope.fuelPricing",$scope.fuelPricing)
5983d987a   Kuldeep Arora   jetmargin api
682
              for (var i = 0; i < $scope.fuelPricing.length; i++) {
64b3dc0e3   Kuldeep Arora   omit vendor and c...
683
                //  console.log('$scope.fuelPricing[i].fuelPricing', $scope.fuelPricing[i].fuelPricing);
dadb46117   Kuldeep Arora   color code for va...
684
                //console.log("fuelid",$scope.fuelPricing[i].fuelPricing.id,"getid",$scope.omitData[j].id)
5983d987a   Kuldeep Arora   jetmargin api
685
686
687
688
689
690
691
692
                  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
693
694
695
696
697
                  // for (var j = 0; j<$scope.omitData.length; j++) {
                  //     if($scope.fuelPricing[i].fuelPricing.id === $scope.omitData[j].id){
  
                  //     }
                  // }
5983d987a   Kuldeep Arora   jetmargin api
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
              }
          })
  
          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
715
          $scope.cancelAircraft = function() {
5983d987a   Kuldeep Arora   jetmargin api
716
717
718
719
720
721
722
723
724
725
              $('#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 ...
726

5983d987a   Kuldeep Arora   jetmargin api
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
754
755
756
757
          $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 ...
758
              }
676250262   Kuldeep Arora   enhancement fuel ...
759

5983d987a   Kuldeep Arora   jetmargin api
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
  
          }
  
          $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 ...
785
              })
5983d987a   Kuldeep Arora   jetmargin api
786
          }
bcd6c1025   Kuldeep Arora   aircraft display-...
787
      
5983d987a   Kuldeep Arora   jetmargin api
788
789
790
          $scope.updateOmit = function(fuel, omit) {
              $scope.fuelData = {};
              $scope.fuelData.expirationDate = new Date(fuel.expirationDate);
bfbbd8668   Kuldeep Arora   UI service
791
              $scope.fuelData.customMarginId = fuel.id;
5983d987a   Kuldeep Arora   jetmargin api
792
793
794
795
              $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
796
              $scope.fuelData.companyId = $scope.compId ;
bfbbd8668   Kuldeep Arora   UI service
797
798
              if($scope.fuelData.omit == true)
              {
bfbbd8668   Kuldeep Arora   UI service
799
                  var customData = "companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId;
20b4aefe7   Kuldeep Arora   viewcompany
800
               //   console.log(".")
bfbbd8668   Kuldeep Arora   UI service
801
802
803
804
805
806
807
808
809
810
811
812
                   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...
813
814
                       var data ="companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId;
                  ViewCompanyService.omitDeleteCompanyFuel(data).then(function(result){
bfbbd8668   Kuldeep Arora   UI service
815
816
817
818
819
820
821
822
823
824
825
                          if (result.success) {
                          toastr.success('' + result.success + '', {
                              closeButton: true
                          })
                        } else {
                          toastr.error('' + result.statusText + '', {
                              closeButton: true
                          })
                      }
                  })
              }
5983d987a   Kuldeep Arora   jetmargin api
826
          }
bfbbd8668   Kuldeep Arora   UI service
827

bcd6c1025   Kuldeep Arora   aircraft display-...
828
          //--fuel type based on tail is not in use--
5983d987a   Kuldeep Arora   jetmargin api
829
          // $scope.aircraftData = {}
1d6e37847   Kuldeep Arora   fueltype in addin...
830
          /*$scope.checkJetWithTail = function(tail, index) {
5983d987a   Kuldeep Arora   jetmargin api
831

1d6e37847   Kuldeep Arora   fueltype in addin...
832
                console.log("tail==============",tail, index)
5983d987a   Kuldeep Arora   jetmargin api
833
              ViewCompanyService.checkJetType(tail).then(function(result) {
1d6e37847   Kuldeep Arora   fueltype in addin...
834
                     console.log("result",result)
5983d987a   Kuldeep Arora   jetmargin api
835
836
837
838
839
840
841
                  if (result.jetA == "true") {
                      $scope.jetShow[index] = false;
                      $scope.marginShow[index] = true;
                  } else {
                      $scope.jetShow[index] = true;
                      $scope.marginShow[index] = false;
                  }
676250262   Kuldeep Arora   enhancement fuel ...
842
              })
1d6e37847   Kuldeep Arora   fueltype in addin...
843
          }*/
5983d987a   Kuldeep Arora   jetmargin api
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
  
          /*add a fuel order*/
  
  
          $scope.getOrders = function() {
              fuelOrdersService.getOrders().then(function(result) {
  
                  $scope.orderdata = result;
                  for (var i = 0; i < $scope.orderdata.length; i++) {
                      $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate);
  
                      // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear()
                      var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear()
                      //  str = str.slice(4,16)
                      $scope.orderdata[i].upliftDateString = str
                      // console.log(str);
  
                  }
  
                  $scope.displayFuelOrderList = new NgTableParams({
                      page: 1,
                      count: 10,
                  }, {
                      data: $scope.orderdata
                  });
                  $(document).ready(function() {
                      var myselect = document.getElementsByClassName('colorfulSelectbox');
  
                      for (var i = 0; i < myselect.length; i++) {
                          var colourIndex = $(myselect[i]).prop('selectedIndex');
                          colourIndex = colourIndex + 1;
                          // console.log(colourIndex);
                          var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color');
                          $(myselect[i]).css('background-color', getColor);
                          // console.log('colour', getColor);
                          myselect[i].blur();
                      }
676250262   Kuldeep Arora   enhancement fuel ...
881
                  })
5983d987a   Kuldeep Arora   jetmargin api
882

676250262   Kuldeep Arora   enhancement fuel ...
883
              })
5983d987a   Kuldeep Arora   jetmargin api
884
885
886
          }
  
          $scope.getOrders();
9d840540f   Anchit Jindal   fixed bugs and ne...
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
          
          $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
917
918
919
      		$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...
920
921
922
923
924
925
926
927
928
929
930
      		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
931
                  })
9d840540f   Anchit Jindal   fixed bugs and ne...
932
933
      		})
      	}
5983d987a   Kuldeep Arora   jetmargin api
934
935
936
937
938
939
940
941
942
943
  
          $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
944
              $scope.selectedCompanyName = company;
9d840540f   Anchit Jindal   fixed bugs and ne...
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
              
              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
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
              }
  
          }
  
          $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 ...
994
              $('#demo-modal-4').css('display', '');
5983d987a   Kuldeep Arora   jetmargin api
995
996
997
998
          }
  
          $scope.setFuel = function() {
              $('#demo-modal-4').css('display', 'block');
676250262   Kuldeep Arora   enhancement fuel ...
999

5983d987a   Kuldeep Arora   jetmargin api
1000
          }
676250262   Kuldeep Arora   enhancement fuel ...
1001

cf43d578a   Kuldeep Arora   delete company up...
1002
          /*delete company*/
5983d987a   Kuldeep Arora   jetmargin api
1003
1004
          var deletecompanyId = "";
          $scope.deleteComp = function(companyDataid) {
cf43d578a   Kuldeep Arora   delete company up...
1005
1006
1007
1008
              $('#delete2').css('display', 'block');
              //console.log("asda",companyDataid)
              deletecompanyId = companyDataid;
          }
1d7e82fdd   Anchit Jindal   fixed bug
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
          $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...
1023

1d7e82fdd   Anchit Jindal   fixed bug
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
          $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
1041
          $scope.deleteCompanyData = function() {
cf43d578a   Kuldeep Arora   delete company up...
1042
              ViewCompanyService.deleteCompany(deletecompanyId).then(function(result) {
cf43d578a   Kuldeep Arora   delete company up...
1043

5983d987a   Kuldeep Arora   jetmargin api
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
                  $('#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...
1062

5983d987a   Kuldeep Arora   jetmargin api
1063
1064
          $scope.editJetMargin = function(aircraftData, type) {
              $scope.showLoader = true;
6c5a99488   Kuldeep Arora   analytics and fue...
1065
              if (type == 'jet') {
cca8fa318   Kuldeep Arora   aircraft display ...
1066
                  
5983d987a   Kuldeep Arora   jetmargin api
1067
                  var aircraftdataMargin = "marginId=" + aircraftData.aircraftsMargin.id + "&type=" + type;
cca8fa318   Kuldeep Arora   aircraft display ...
1068
                  
5983d987a   Kuldeep Arora   jetmargin api
1069
              } else {
5983d987a   Kuldeep Arora   jetmargin api
1070
                  var aircraftdataMargin = "marginId=" + aircraftData.aircraftsAVGASMargin.id + "&type=" + type;
cf43d578a   Kuldeep Arora   delete company up...
1071
              }
5983d987a   Kuldeep Arora   jetmargin api
1072
1073
1074
1075
1076
1077
1078
1079
  
              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-...
1080
1081
                     // getAircraftWithMarginList();
                     getAircraftList();
5983d987a   Kuldeep Arora   jetmargin api
1082
1083
1084
1085
1086
1087
1088
1089
                  } else {
                      $scope.showLoader = false;
                      toastr.error('' + result.statusText + '', {
                          closeButton: true
                      })
                  }
              })
          }
cca8fa318   Kuldeep Arora   aircraft display ...
1090
1091
  
          /* //not used currently 
5983d987a   Kuldeep Arora   jetmargin api
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
          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...
1113
              })
cca8fa318   Kuldeep Arora   aircraft display ...
1114
          }*/
40c8c308c   Kuldeep Arora   omit css
1115

40c8c308c   Kuldeep Arora   omit css
1116

5983d987a   Kuldeep Arora   jetmargin api
1117
      }]);