Blame view

app/partials/viewCompany/viewCompany.controller.js 22 KB
feacde5ff   Rishav   setup acuefuel in...
1
2
3
4
5
  
  'use strict';
  
   //Load controller
    angular.module('acufuel')
cdf775224   Anchit Jindal   fixed company and...
6
  	.controller('viewCompanyController', ['$scope','$uibModal', '$stateParams', 'ViewCompanyService', 'CustomersService', 'updateFuelManagerService', 'ViewFuelVendorService', 'ViewcontactService', function($scope , $uibModal, $stateParams, ViewCompanyService, CustomersService, updateFuelManagerService, ViewFuelVendorService, ViewcontactService) {
55e075d7e   Rishav   add contact, add ...
7
8
          $scope.data = {};
          $scope.data.priceEmail = true;
b1f6160d4   Rishav   add contact and a...
9
          $scope.aircraft = {};
3a9f4472b   Rishav   Implement contact...
10
          $scope.primayData = {};
d24318592   Rishav   changes and new i...
11
          $scope.showLoader = false;
ba1d39503   Swarn Singh   view company form...
12
          $scope.showUpdateBtn = false;
28af27a3f   Rishav   add fuelPriceapi
13
          $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId'));
97f8c67f9   Rishav Singla   ui select impplem...
14
          $scope.selected = [];
3a9f4472b   Rishav   Implement contact...
15

7152ff131   Rishav   model handle
16
17
18
19
20
          $(document).ready(function() {
              $("#reset").click(function() {
                  $("input").val("");
              });
          });
97f8c67f9   Rishav Singla   ui select impplem...
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
          $scope.values = [
            {'id': 1, 'first': 'Tenant/Base Customer'}, 
            {'id': 2, 'first': 'FuelerLinx Customer'},
            {'id': 3, 'first': 'CAA Member'}
          ];
  
          $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;
              }
  
              if(selected[i] == 'CAA Member'){
                $scope.companyData.contractFuelVendor = true;
              }else{
                $scope.companyData.contractFuelVendor = false;
              }
  
              console.log($scope.companyData)
              
            }
  
          }
  
          // $scope.selected =[
          //   {'id': 1, 'first': 'Tenant/Base Customer'}, 
          //   {'id': 2, 'first': 'FuelerLinx Customer'},
          //   {'id': 3, 'first': 'CAA Member'}
          // ];
d1fe89776   Rishav Singla   view fuel vendor ...
60
61
62
          // CustomersService.getMargin().then(function(result) {
          //   $scope.marginList = result;
          // })
3a9f4472b   Rishav   Implement contact...
63

48ed0c7bb   Rishav   update company co...
64
          var value = "";
55e075d7e   Rishav   add contact, add ...
65
          var companyId = $stateParams.id;
a9a8f570d   Anchit Jindal   new desing implem...
66
67
68
          $scope.companyData = {};
          $scope.multipleMsg = false;
          $scope.companyData.masterMargin = "";
a9aef0b1c   Anchit Jindal   new changes imple...
69
          $scope.isGlobal = false;
e9a2edf03   Rishav   update custom field
70
71
          getCompanyDetail();
          function getCompanyDetail(){
05bfa28a2   Mr. Hot Foods   remove save butto...
72
            $scope.showLoader = true;
e9a2edf03   Rishav   update custom field
73
74
            ViewCompanyService.getCompany(companyId).then(function(result) {
              $scope.companyData = result;
a9aef0b1c   Anchit Jindal   new changes imple...
75
              $scope.isGlobal = result.global;
97f8c67f9   Rishav Singla   ui select impplem...
76
77
78
              if(result.global == true){
                $scope.companyData.global = true;
              }
e9a2edf03   Rishav   update custom field
79
80
81
              if(result.margin != null){
                 $scope.companyData.masterMargin = result.margin.id;
              }
a9a8f570d   Anchit Jindal   new desing implem...
82
83
84
              if(result.marginAVGAS != null){
                  $scope.companyData.avgasMargin = result.marginAVGAS.id;
               }
97f8c67f9   Rishav Singla   ui select impplem...
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
               
  
  
               if($scope.companyData.baseTenant){
                
                $scope.selected.push({'first': 'Tenant/Base Customer'})
                console.log("$scope.selected",$scope.selected)
  
               }
  
               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)
7ee64838c   Anchit Jindal   new desing implem...
106
              getAircraftList();
e9a2edf03   Rishav   update custom field
107
108
109
110
              $scope.showLoader = false;
            })
          }
          
55e075d7e   Rishav   add contact, add ...
111

74c8ae4bb   Rishav   remove old toogle...
112
          $scope.changeCompanyStatus = function(){
da24c95c8   Rishav Singla   confirmation mess...
113
114
115
116
117
118
119
120
121
              $('#delete3').css('display', 'block');
              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?'
              }
          }
  
          $scope.companyStatus = function(){
05bfa28a2   Mr. Hot Foods   remove save butto...
122
            $scope.showLoader = true;
3a9f4472b   Rishav   Implement contact...
123
124
              var statusData = "status=" + $scope.companyData.activate;
              ViewCompanyService.changeStatus(companyId, statusData).then(function(result) {
c555af312   Rishav   price email, comp...
125
                if(result.success){
da24c95c8   Rishav Singla   confirmation mess...
126
                    $('#delete3').css('display', 'none');
c555af312   Rishav   price email, comp...
127
128
129
                    toastr.success(''+result.success+'', {
                        closeButton: true
                    })
6efd9a0a8   Anchit Jindal   new desing changes
130
                    getContactList();
c555af312   Rishav   price email, comp...
131
                }
3a9f4472b   Rishav   Implement contact...
132
              })
05bfa28a2   Mr. Hot Foods   remove save butto...
133
              $scope.showLoader = false;
c555af312   Rishav   price email, comp...
134
          }
3a9f4472b   Rishav   Implement contact...
135

8670c5905   Jaideep Singh   new changes
136
          
da24c95c8   Rishav Singla   confirmation mess...
137
138
139
140
          $scope.cancelStatus = function(){
              $('#delete3').css('display', 'none');
              $scope.companyData.activate =  !$scope.companyData.activate;
          }
3a9f4472b   Rishav   Implement contact...
141
          
48ed0c7bb   Rishav   update company co...
142
143
144
145
146
147
          getContactList();
          function getContactList(){
            ViewCompanyService.getContact(companyId).then(function(result) {
              $scope.companyContactList = result;
            })
          }
a9a8f570d   Anchit Jindal   new desing implem...
148
          $scope.aircraftmargins = [];
7ee64838c   Anchit Jindal   new desing implem...
149
         
b1f6160d4   Rishav   add contact and a...
150
151
152
          function getAircraftList(){
            ViewCompanyService.getAircraft(companyId).then(function(result) {
              $scope.contactAircraftList = result;
a9a8f570d   Anchit Jindal   new desing implem...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
              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";
                          }
                  	}
                  }
              }
b1f6160d4   Rishav   add contact and a...
171
172
            })
          }
b1f6160d4   Rishav   add contact and a...
173

55e075d7e   Rishav   add contact, add ...
174
175
176
          $scope.contactData = {};
          $scope.contactData.contactList = [];
          $scope.addContact = function(){
05bfa28a2   Mr. Hot Foods   remove save butto...
177
            $scope.showLoader = true;
55e075d7e   Rishav   add contact, add ...
178
179
            $scope.data.companyId = companyId;
            $scope.contactData.contactList.push($scope.data);
55e075d7e   Rishav   add contact, add ...
180
            ViewCompanyService.addContact($scope.contactData).then(function(result) {
3a9f4472b   Rishav   Implement contact...
181
182
183
184
185
              console.log(result)
              if(result.status == 200){
                  // toastr.success(''+result.success+'', {
                  //   closeButton: true
                  // })
55e075d7e   Rishav   add contact, add ...
186
                  $('#contact-modal-3').modal('hide');
3a9f4472b   Rishav   Implement contact...
187
                  $scope.primayData.id = result.data;
d1fe89776   Rishav Singla   view fuel vendor ...
188
                  $scope.data = {};
3a9f4472b   Rishav   Implement contact...
189
                  $scope.sendPrimaryContact();
48ed0c7bb   Rishav   update company co...
190
                  getContactList();
55e075d7e   Rishav   add contact, add ...
191
192
193
194
195
196
              }else{
                toastr.error(''+result.statusText+'', {
                    closeButton: true
                  })
              }
            })
05bfa28a2   Mr. Hot Foods   remove save butto...
197
            $scope.showLoader = false;
55e075d7e   Rishav   add contact, add ...
198
          }
feacde5ff   Rishav   setup acuefuel in...
199

b1f6160d4   Rishav   add contact and a...
200
201
        getData();
        function getData(){
05bfa28a2   Mr. Hot Foods   remove save butto...
202
          $scope.showLoader = true;
b1f6160d4   Rishav   add contact and a...
203
204
205
          CustomersService.getAircraftMake().then(function(result) {
            $scope.aircraftMakeList = result;
          })
05bfa28a2   Mr. Hot Foods   remove save butto...
206
          $scope.showLoader = false;
b1f6160d4   Rishav   add contact and a...
207
208
        }
        
a4884cfe7   Rishav   add aircraft issu...
209
210
211
        $scope.clearAircrafts = function(){
          $scope.aircraftDetails = [];
          $scope.aircraftDetails = [{ 
b1f6160d4   Rishav   add contact and a...
212
213
214
              'tail':'',
              'make': '',
              'model': '',
3a9f4472b   Rishav   Implement contact...
215
              'sizeId' : '',
7ee64838c   Anchit Jindal   new desing implem...
216
217
              'marginId': '',
          	'avgasMarginId': ''
b1f6160d4   Rishav   add contact and a...
218
          }];
a4884cfe7   Rishav   add aircraft issu...
219
        }
b1f6160d4   Rishav   add contact and a...
220
      
a4884cfe7   Rishav   add aircraft issu...
221
222
223
224
225
226
        $scope.addNew = function(){
            $scope.aircraftDetails.push({ 
              'tail':'',
              'make': '',
              'model': '',
              'sizeId' : '',
7ee64838c   Anchit Jindal   new desing implem...
227
228
              'marginId': '',
          	'avgasMarginId': ''
a4884cfe7   Rishav   add aircraft issu...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
            });
            console.log($scope.aircraftDetails)
        };
  
        $scope.getModal = function(makeId, index){
        $scope.showLoader = true;
        $scope.aircraft.make = makeId;
          //var makeId = makeId;
          CustomersService.getModal($scope.aircraft.make).then(function(result) {
            $scope.showLoader = false;
            $scope.aircraftDetails[index].aircraftModalList = result;
            //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0];
          })
        }
b1f6160d4   Rishav   add contact and a...
243

a4884cfe7   Rishav   add aircraft issu...
244
        $scope.getSize = function(model, index){
d24318592   Rishav   changes and new i...
245
          $scope.showLoader = true;
a4884cfe7   Rishav   add aircraft issu...
246
247
248
249
250
251
          CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) {
            $scope.showLoader = false;
            $scope.aircraftDetails[index].aircraftSizeList = result;
            //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0];
          })
        }
b1f6160d4   Rishav   add contact and a...
252

a4884cfe7   Rishav   add aircraft issu...
253
254
255
256
257
258
259
260
261
262
        $scope.aircraftListData = {};
        //$scope.addData = [];
        $scope.saveCompanyData = function(){
          for(var i=0; i<$scope.aircraftDetails.length;i++){
            $scope.addData = [];
            $scope.addData.push({ 
                'tail': $scope.aircraftDetails[i].tail,
                'make': $scope.aircraftDetails[i].make,
                'model': $scope.aircraftDetails[i].model,
                'sizeId' : $scope.aircraftDetails[i].sizeId,
7ee64838c   Anchit Jindal   new desing implem...
263
264
                'marginId': $scope.aircraftDetails[i].marginId,
  	          'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId
a4884cfe7   Rishav   add aircraft issu...
265
              });
b1f6160d4   Rishav   add contact and a...
266
          }
a4884cfe7   Rishav   add aircraft issu...
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
          console.log($scope.addData)
          $scope.aircraftListData.aircraftList = $scope.addData;
          $scope.aircraftListData.accountId = companyId;
          
          CustomersService.addAircraft($scope.aircraftListData).then(function(result) {
            if(result != null && result.success){
              toastr.success(''+result.success+'', {
                  closeButton: true
                })
                $('#aircraft-modal-3').modal('hide');
                getAircraftList();
            }else{
              toastr.error(''+result.statusText+'', {
                  closeButton: true
                })
b1f6160d4   Rishav   add contact and a...
282
            }
a4884cfe7   Rishav   add aircraft issu...
283
          });
b1f6160d4   Rishav   add contact and a...
284
            
a4884cfe7   Rishav   add aircraft issu...
285
286
287
288
289
290
291
292
293
294
295
296
297
        }
        $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;
        }
7152ff131   Rishav   model handle
298
299
300
        $scope.base = function(){
          $scope.showUpdateBtn = true;
        }
a4884cfe7   Rishav   add aircraft issu...
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
        $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;              
            }*/
            $scope.showNoteData = true;
            $scope.showCompanyName = true;
            $scope.showAddress = true;
a9a8f570d   Anchit Jindal   new desing implem...
319
            var companyData = "companyName=" + $scope.companyData.companyName + "&masterMargin=" + $scope.companyData.masterMargin + "&avgasMargin=" + $scope.companyData.avgasMargin
a4884cfe7   Rishav   add aircraft issu...
320
321
322
323
              + "&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 
97f8c67f9   Rishav Singla   ui select impplem...
324
              + "&activate=" + $scope.companyData.activate + "&baseIcao=" + $scope.companyData.baseIcao + "&companyId=" + companyId + "&global=" + $scope.companyData.global;
a4884cfe7   Rishav   add aircraft issu...
325

cdf775224   Anchit Jindal   fixed company and...
326
            ViewCompanyService.updateCompany(companyData).then(function(result) {
b1f6160d4   Rishav   add contact and a...
327
328
              if(result != null && result.success){
                toastr.success(''+result.success+'', {
a4884cfe7   Rishav   add aircraft issu...
329
330
331
                  closeButton: true
                })
                $scope.showUpdateBtn = false;
cdf775224   Anchit Jindal   fixed company and...
332
                getCompanyDetail();
b1f6160d4   Rishav   add contact and a...
333
334
              }else{
                toastr.error(''+result.statusText+'', {
a4884cfe7   Rishav   add aircraft issu...
335
336
337
                  closeButton: true
                })
                $scope.showUpdateBtn = true;
b1f6160d4   Rishav   add contact and a...
338
              }
a4884cfe7   Rishav   add aircraft issu...
339
340
              $scope.showLoader = false;
            })
a4884cfe7   Rishav   add aircraft issu...
341
        }
b1f6160d4   Rishav   add contact and a...
342

7152ff131   Rishav   model handle
343
344
345
346
347
348
        $scope.cancelData = function(){
            $scope.showNoteData = true;
            $scope.showCompanyName = true;
            $scope.showAddress = true;
            $scope.showUpdateBtn = false;
        }
a4884cfe7   Rishav   add aircraft issu...
349
        $scope.sendMail = function(){
d1fe89776   Rishav Singla   view fuel vendor ...
350
          $('#confirm1').css('display', 'none');
a4884cfe7   Rishav   add aircraft issu...
351
352
353
354
355
          ViewCompanyService.sendMail(companyId).then(function(result) {
              if(result != null && result.success){
                toastr.success(''+result.success+'', {
                  closeButton: true
                })
a4884cfe7   Rishav   add aircraft issu...
356
357
358
359
360
361
362
              }else{
                toastr.error(''+result.statusText+'', {
                  closeButton: true
                })
              }
          })
        }
b1f6160d4   Rishav   add contact and a...
363

a4884cfe7   Rishav   add aircraft issu...
364
365
366
        $scope.openConfirmMail = function(){
          $('#confirm1').css('display', 'block');
        }
48ed0c7bb   Rishav   update company co...
367

b1f6160d4   Rishav   add contact and a...
368

a4884cfe7   Rishav   add aircraft issu...
369
370
371
        $scope.cancelAndCloseConfirm = function(){
          $('#confirm1').css('display', 'none');
        }
6efd9a0a8   Anchit Jindal   new desing changes
372
373
        
        $scope.primaryContact = false;
a4884cfe7   Rishav   add aircraft issu...
374
375
376
377
        $scope.cancelPrimaryContact = function(){
          $('#primaryContact').css('display', 'none');
          $scope.primaryContact = false;
        }
3a9f4472b   Rishav   Implement contact...
378

a4884cfe7   Rishav   add aircraft issu...
379
380
        $scope.checkPrimaryContact = function(){
          if($scope.primaryContact == true){
6efd9a0a8   Anchit Jindal   new desing changes
381
382
383
384
385
386
387
          	$scope.primaryContact = true;
          	ViewCompanyService.checkPrimaryContact(companyId).then(function(result) {
          		console.log(result)
  				if(result.status == 422){
  				  $('#primaryContact').css('display', 'block');
  				}
          	})
3a9f4472b   Rishav   Implement contact...
388
          }
a4884cfe7   Rishav   add aircraft issu...
389
        }
3a9f4472b   Rishav   Implement contact...
390

a4884cfe7   Rishav   add aircraft issu...
391
        $scope.sendPrimaryContact = function(){
a4884cfe7   Rishav   add aircraft issu...
392
393
394
          $('#primaryContact').css('display', 'none');
          if($scope.primayData.id != null || $scope.primayData.id != undefined){
            var priamryContactData = "companyContactId=" + $scope.primayData.id + "&primary=" + $scope.primaryContact;
3a9f4472b   Rishav   Implement contact...
395

a4884cfe7   Rishav   add aircraft issu...
396
397
398
            ViewCompanyService.addPrimaryContact(priamryContactData).then(function(result) {
              console.log(result)
            })
3a9f4472b   Rishav   Implement contact...
399
          }
a4884cfe7   Rishav   add aircraft issu...
400
401
          
        }
3a9f4472b   Rishav   Implement contact...
402

a4884cfe7   Rishav   add aircraft issu...
403
404
405
406
407
408
409
410
411
412
413
        var newContactName = "";
        $scope.updateData = ""
        $scope.showContact = function(data, value){
          $('#updateContact').css('display', 'block');
          $scope.updateData = data;
          newContactName = value;
          console.log($scope.updateData)
          if($scope.updateData.email == null){
            $scope.updateData.content = data.contactNumber;
          }else{
            $scope.updateData.content = data.email;
3a9f4472b   Rishav   Implement contact...
414
          }
a4884cfe7   Rishav   add aircraft issu...
415
        }
3a9f4472b   Rishav   Implement contact...
416

a4884cfe7   Rishav   add aircraft issu...
417
418
419
420
421
422
423
424
425
426
        $scope.acceptUpdateField = function(){
          console.log($scope.updateData)
          if($scope.updateData.content == undefined){
            toastr.error('Please add some content', {
              closeButton: true
            })
          }else{
            if(newContactName == 'phone'){
              var updateCustomData = "companyId=" + companyId + "&contactNumber=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id
                + "&title=" + $scope.updateData.title;
e9a2edf03   Rishav   update custom field
427
            }else{
a4884cfe7   Rishav   add aircraft issu...
428
429
              var updateCustomData = "companyId=" + companyId + "&email=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id
                + "&title=" + $scope.updateData.title;
e9a2edf03   Rishav   update custom field
430
            }
a4884cfe7   Rishav   add aircraft issu...
431
432
433
434
435
            ViewCompanyService.updateCustomField(updateCustomData).then(function(result) {
              console.log(result)
              if(result != null && result.success){
                $('#updateContact').css('display', 'none');
                getCompanyDetail();
e9a2edf03   Rishav   update custom field
436
              }
a4884cfe7   Rishav   add aircraft issu...
437
            })
e9a2edf03   Rishav   update custom field
438
          }
a4884cfe7   Rishav   add aircraft issu...
439
        }
e9a2edf03   Rishav   update custom field
440

a4884cfe7   Rishav   add aircraft issu...
441
442
443
        $scope.cancelUpdateField = function(){
          $('#updateContact').css('display', 'none');
        }
e9a2edf03   Rishav   update custom field
444

a4884cfe7   Rishav   add aircraft issu...
445
446
447
448
        $scope.showEditTier2 = function(number){
          console.log(number)
          $scope.contactNumber = number;
        }
8f88e39ed   Rishav   add custom field ...
449

e9a2edf03   Rishav   update custom field
450

a4884cfe7   Rishav   add aircraft issu...
451
452
453
454
455
456
        var contactName = '';
        $scope.addCustom = function(value){
          console.log(value)
          if(value != null){
            contactName = value;
            $('#customField').css('display', 'block');
3a9f4472b   Rishav   Implement contact...
457
          }
7152ff131   Rishav   model handle
458
          $scope.custom = {};
a4884cfe7   Rishav   add aircraft issu...
459
        }
8f88e39ed   Rishav   add custom field ...
460

a4884cfe7   Rishav   add aircraft issu...
461
462
463
        $scope.cancelCustomField = function(){
          $('#customField').css('display', 'none');
        }
7152ff131   Rishav   model handle
464
        
a4884cfe7   Rishav   add aircraft issu...
465
466
467
468
469
470
471
472
473
        $scope.acceptCustomField = function(){
          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;
3a9f4472b   Rishav   Implement contact...
474
            }else{
a4884cfe7   Rishav   add aircraft issu...
475
476
              var customData = "companyId=" + companyId + "&email=" + $scope.custom.content 
                + "&title=" + $scope.custom.title;
d24318592   Rishav   changes and new i...
477
            }
a4884cfe7   Rishav   add aircraft issu...
478
479
480
481
482
483
484
485
            console.log(customData.email)
            ViewCompanyService.addCustomField(customData).then(function(result) {
              console.log(result)
              if(result != null && result.success){
                $('#customField').css('display', 'none');
                getCompanyDetail();
              }
            })
3a9f4472b   Rishav   Implement contact...
486
          }
a4884cfe7   Rishav   add aircraft issu...
487
        }
28af27a3f   Rishav   add fuelPriceapi
488

7152ff131   Rishav   model handle
489
        updateFuelManagerService.getFuelPricingNew().then(function(result) {
28af27a3f   Rishav   add fuelPriceapi
490
491
          $scope.fuelPricing = result;
          for (var i = 0; i<$scope.fuelPricing.length; i++) {
7152ff131   Rishav   model handle
492
            if ($scope.fuelPricing[i].fuelPricing.expirationDate != null) {
a9e3a7365   Swarn Singh   fix issues on vie...
493
494
495
496
497
498
                $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;
28af27a3f   Rishav   add fuelPriceapi
499
500
501
            }
          }
        })
67044e31e   Rishav Singla   modify changes an...
502

da24c95c8   Rishav Singla   confirmation mess...
503
        var deleteAircraftId = "";
67044e31e   Rishav Singla   modify changes an...
504
        $scope.deleteAircraft = function(id){
da24c95c8   Rishav Singla   confirmation mess...
505
506
507
508
509
510
            $('#delete1').css('display', 'block');
            deleteAircraftId = id;
        }
  
        $scope.aircraftDelete = function(){
            ViewCompanyService.deleteAircraft(deleteAircraftId).then(function(result) {
67044e31e   Rishav Singla   modify changes an...
511
512
              console.log(result)
              getAircraftList();
6efd9a0a8   Anchit Jindal   new desing changes
513
              getCompanyDetail();
da24c95c8   Rishav Singla   confirmation mess...
514
              $('#delete1').css('display', 'none');
67044e31e   Rishav Singla   modify changes an...
515
516
            })
        }
da24c95c8   Rishav Singla   confirmation mess...
517
518
519
520
  
        $scope.cancelDelete = function(){
          $('#delete1').css('display', 'none');
        }
a9a8f570d   Anchit Jindal   new desing implem...
521
        
da24c95c8   Rishav Singla   confirmation mess...
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
      	CustomersService.getJetMargin($scope.userProfileId).then(function(result) {
    		  $scope.jetMarginList = result;
    		})
  
    		CustomersService.getAvgMargin($scope.userProfileId).then(function(result) {
    		  $scope.avgsMarginList = result;
    		})
  
         $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';
                    }
                }
            })
          }
a9a8f570d   Anchit Jindal   new desing implem...
545

da24c95c8   Rishav Singla   confirmation mess...
546
547
548
          $scope.cancelToogle = function(){
            $('#toogleMail').css('display', 'none');
          }
8670c5905   Jaideep Singh   new changes
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
  
           $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.'
              }
  
              
          }
  
         $scope.fuelerCancelStatus = function(){
              $('#fuelerchange').css('display', 'none');
              $scope.companyData.fuelerlinxCustomer =  !$scope.companyData.fuelerlinxCustomer;
          }
  
          $scope.fuelerAcceptStatus = function(){
cdf775224   Anchit Jindal   fixed company and...
572
573
            $('#fuelerchange').css('display', 'none');
            $scope.showLoader = true;
8670c5905   Jaideep Singh   new changes
574
575
576
577
578
579
580
581
            var statusData;
            if($scope.companyData.fuelerlinxCustomer == false){
              statusData = "status=true";
            } else {
              statusData = "status=false";
            }
            ViewCompanyService.fuelerPricingChange(companyId, statusData).then(function(result) {
              if(result.success){
cdf775224   Anchit Jindal   fixed company and...
582
              	$scope.showLoader = false;
8670c5905   Jaideep Singh   new changes
583
584
585
586
587
588
589
                    
                    $scope.editData();
                    getContactList();
                    
                }
            })
          }
a4884cfe7   Rishav   add aircraft issu...
590
          
cdf775224   Anchit Jindal   fixed company and...
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
          $scope.updateOmit = function(fuel, omit) {
        	  $scope.fuelData = {};
        	  $scope.fuelData.expirationDate = new Date(fuel.expirationDate);
        	  $scope.fuelData.id = fuel.id;
        	  $scope.fuelData.omit = fuel.omit;
        	  $scope.fuelData.papMargin = fuel.papMargin;
        	  $scope.fuelData.papTotal = fuel.papTotal;
        	  $scope.fuelData.cost = fuel.cost;
        	  ViewFuelVendorService.omitFuelPricing($scope.fuelData).then(function(result) {
              if(result.success){
            	  toastr.success(''+result.success+'', {
                      closeButton: true
                  })
              }else{
            	  toastr.error(''+result.statusText+'', {
            		  closeButton: true
            	  })
              }
        	  })
          }
          
55e075d7e   Rishav   add contact, add ...
612
    }]);