Blame view

app/partials/fuelOrders/fuelOrders.controller.js 22.4 KB
4bb02bb84   Rishav   new integration w...
1
  'use strict';
6284a85b9   Jaideep Singh   fuel orders page ...
2
  angular.module('acufuel')
e33b4556c   Kuldeep Arora   bugs resolved
3
  .controller('fuelOrdersController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'NgTableParams','fuelOrdersService','CustomersService','ViewCompanyService', fuelOrdersController]);
6284a85b9   Jaideep Singh   fuel orders page ...
4

e33b4556c   Kuldeep Arora   bugs resolved
5
  function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgTableParams,fuelOrdersService,CustomersService,ViewCompanyService) {
6284a85b9   Jaideep Singh   fuel orders page ...
6

e33b4556c   Kuldeep Arora   bugs resolved
7
8
9
10
11
12
13
14
15
        $scope.showFuelOrderModal = false;
        $scope.optionSelected;
        $scope.orderdata = {}
        $scope.showLoader = false;
        $scope.jetShow = [];
        $scope.marginShow = [];
  
        $scope.jetShow[0] = true;
        $scope.marginShow[0] = true;
6284a85b9   Jaideep Singh   fuel orders page ...
16

e33b4556c   Kuldeep Arora   bugs resolved
17
18
19
20
        $scope.data = {};
        $scope.order = {};
        $scope.dispatchOrder = {};
    	  $scope.dispatchOrder.fuelOrderList = [];
8d682e773   Mr. Hot Foods   changes in fuel o...
21

e33b4556c   Kuldeep Arora   bugs resolved
22
23
        $scope.statusFilterOptions = [];
        $scope.statusFilterOptions.push({
8d682e773   Mr. Hot Foods   changes in fuel o...
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  		  	'id': '', 'title': 'Show All'
  		  },{
  		  	'id': 'pending', 'title': 'Pending'
  		  },{
  		  	'id': 'invoiced', 'title': 'Invoiced'
  		  },{
  		  	'id': 'paid', 'title': 'Paid'
  		  },{
  		  	'id': 'cancelled', 'title': 'Cancelled'
  		  },{
  		  	'id': 'archived', 'title': 'Archived'
  		  }
       
        );
e33b4556c   Kuldeep Arora   bugs resolved
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
        getAllCompanies();
  
      function getAllCompanies(){
        fuelOrdersService.getAllCompanies().then(function(result) {
         // console.log('log', result);
          $scope.companyList = result;
          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;
        })
      }
  
  
      $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId'))
      $scope.reset2 = function(){
        $("input").val("");
        $scope.removeMarginValidation();
      }
5a7920053   Swarn Singh   selectbox color i...
77
78
79
80
      function colourFunction() {
        var myselect = document.getElementById('colorfulSelectbox'),
        colour = myselect.options[myselect.selectedIndex].className;
        myselect.style.background = colour;
e33b4556c   Kuldeep Arora   bugs resolved
81
       // console.log('colour', myselect);
5a7920053   Swarn Singh   selectbox color i...
82
83
84
85
86
87
        myselect.blur();
      }
  
      //setInterval(function(){
       // colourFunction();
      //}, 1)
8d682e773   Mr. Hot Foods   changes in fuel o...
88
89
90
91
92
93
94
95
96
97
  
        $scope.attachmentFilterOptions = [];
      $scope.attachmentFilterOptions.push({
  		  	'id': '', 'title': 'Show All'
  		  },{
  		  	'id': '!null', 'title': 'Attachments'
  		  },{
  		  	'id': 'null', 'title': 'No Attachments'
  		  }
       );
9aae3d136   Mr. Hot Foods   show loaders and ...
98

f100849ce   Mr. Hot Foods   analytics updates
99
100
101
102
103
        //  $(document).ready(function() {
        //     $scope.showLoader = true;
        //       $('#example').DataTable();
        //       $scope.showLoader = false;
        //   });
6284a85b9   Jaideep Singh   fuel orders page ...
104
       
8d682e773   Mr. Hot Foods   changes in fuel o...
105
       $scope.getOrders = function() {
6284a85b9   Jaideep Singh   fuel orders page ...
106
            fuelOrdersService.getOrders().then(function(result) {
9aae3d136   Mr. Hot Foods   show loaders and ...
107
             
6284a85b9   Jaideep Singh   fuel orders page ...
108
109
              $scope.orderdata = result;
              for(var i=0;i<$scope.orderdata.length;i++){
8d682e773   Mr. Hot Foods   changes in fuel o...
110
                  $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate);
6284a85b9   Jaideep Singh   fuel orders page ...
111

b129e1023   Kuldeep Arora   fueling date format
112
113
                  // 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()
8d682e773   Mr. Hot Foods   changes in fuel o...
114
115
                  //  str = str.slice(4,16)
                  $scope.orderdata[i].upliftDateString = str
e33b4556c   Kuldeep Arora   bugs resolved
116
                 // console.log(str);
6284a85b9   Jaideep Singh   fuel orders page ...
117
118
119
120
121
122
123
124
125
  
              }
             
               $scope.displayFuelOrderList = new NgTableParams({
                page: 1,
                count: 10,
              }, {
                data: $scope.orderdata
              });
5a7920053   Swarn Singh   selectbox color i...
126
127
128
129
130
131
              $(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;
e33b4556c   Kuldeep Arora   bugs resolved
132
                 // console.log(colourIndex);
5a7920053   Swarn Singh   selectbox color i...
133
134
                  var getColor = $('.colorfulSelectbox option:nth-child('+colourIndex+')').css('color');
                  $(myselect[i]).css('background-color', getColor);
e33b4556c   Kuldeep Arora   bugs resolved
135
                 // console.log('colour', getColor);
5a7920053   Swarn Singh   selectbox color i...
136
137
138
139
                  myselect[i].blur();
                }
  
              })
9aae3d136   Mr. Hot Foods   show loaders and ...
140
             
6284a85b9   Jaideep Singh   fuel orders page ...
141
            })
8d682e773   Mr. Hot Foods   changes in fuel o...
142
143
144
       }
       
       $scope.getOrders();
3c2c216d6   Kuldeep Arora   direct transactio...
145
       $scope.optionSelected='';
8d682e773   Mr. Hot Foods   changes in fuel o...
146
147
       $scope.onFWSelect = function() {
                          if($scope.optionSelected == 'dt'){
3c2c216d6   Kuldeep Arora   direct transactio...
148
149
                            $('#demo-modal-4').css('display', 'block');
                             $scope.optionSelected='';
8d682e773   Mr. Hot Foods   changes in fuel o...
150
151
152
153
154
155
156
157
158
159
160
161
162
                        }
                        if($scope.optionSelected == 'efo'){
                          	$scope.showLoader = true;
                              var fileName = "orders.csv";
                              var a = document.createElement("a");
                              document.body.appendChild(a);
                              fuelOrdersService.exportCompany().then(function(result) {
                                    var file = new Blob([result], {type: 'application/csv'});
                                    var fileURL = URL.createObjectURL(file);
                                    a.href = fileURL;
                                    a.download = fileName;
                                    a.click();
                                    $scope.showLoader = false;
3c2c216d6   Kuldeep Arora   direct transactio...
163
                                    $scope.optionSelected='';
8d682e773   Mr. Hot Foods   changes in fuel o...
164
165
166
                              })
                          }
                      }
e33b4556c   Kuldeep Arora   bugs resolved
167
       $scope.attachmentrowid = ""
dd378d69f   Mr. Hot Foods   changes in flight...
168

e33b4556c   Kuldeep Arora   bugs resolved
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
       
       $scope.attachment = function(id, value, url) {
    	   // console.log(id, value)
    	    $scope.attachmentrowid = id
    	    //  $scope.attachmentdeleteid = attachdeleteid
    	    if(value == 'uploadAttachment'){
    	    $('#demo-modal-6').css('display', 'block');
    	    }else if(value == 'viewAttachment'){
    	    var win = window.open(url, '_blank');
    	    win.focus();
    	    }else if(value == 'deleteAttachment'){
    	    $('#delete1').css('display', 'block');
    	    }
    	}
  
      $scope.cancelDeleteAttachment = function() {
            $('#delete1').css('display', '');
      }
c277275bb   Mr. Hot Foods   login changes
187

e33b4556c   Kuldeep Arora   bugs resolved
188
189
190
191
      $scope.deleteAttachment = function() {
        $scope.showLoader = true;
        fuelOrdersService.deleteAttachment($scope.attachmentrowid).then(function(result) {
               // console.log(result, $scope.attachmentrowid)
a9aef0b1c   Anchit Jindal   new changes imple...
192

e33b4556c   Kuldeep Arora   bugs resolved
193
194
195
196
197
198
199
200
201
                if(result.success){
                toastr.success(''+result.success+'', {
                          closeButton: true
                      })
                }
            })
            $scope.showLoader = false;
            $('#delete1').css('display', '');
      }
c277275bb   Mr. Hot Foods   login changes
202

dd378d69f   Mr. Hot Foods   changes in flight...
203
     $scope.saveUploadAttachment = function(attachmentData) {
9aae3d136   Mr. Hot Foods   show loaders and ...
204
       $scope.showLoader = true;
38628e5f5   Anchit Jindal   minor changes
205
  	   	$scope.data.media = attachmentData
64e7e5f50   Mr. Hot Foods   view upload delet...
206
  	   	$scope.data.id = $scope.attachmentrowid
38628e5f5   Anchit Jindal   minor changes
207
  		fuelOrdersService.uploadAttachment($scope.data).then(function(result) {
e33b4556c   Kuldeep Arora   bugs resolved
208
             // console.log(result)
a9aef0b1c   Anchit Jindal   new changes imple...
209
210
211
212
213
214
215
216
217
218
219
              if(result){
                // console.log(result.success)
                    toastr.success(''+"Upload Successful"+'', {
                              closeButton: true
                          })
                    }
                    
              })
                $scope.showLoader = false;
                $('#demo-modal-6').css('display', 'none');
          }
dd378d69f   Mr. Hot Foods   changes in flight...
220

e33b4556c   Kuldeep Arora   bugs resolved
221
222
223
      $scope.cancelUploadAttachment = function() {
            $('#demo-modal-6').css('display', 'none');
      }
8d682e773   Mr. Hot Foods   changes in fuel o...
224

e33b4556c   Kuldeep Arora   bugs resolved
225
226
      $scope.editdata = {};
      
8d682e773   Mr. Hot Foods   changes in fuel o...
227

e33b4556c   Kuldeep Arora   bugs resolved
228
229
230
231
      $scope.editTableRow = function(rowData){
       // console.log('row data', rowData);
        $scope.editdata = rowData;
        $('#demo-modal-5').css('display', 'block');
a9aef0b1c   Anchit Jindal   new changes imple...
232
      }
8d682e773   Mr. Hot Foods   changes in fuel o...
233

e33b4556c   Kuldeep Arora   bugs resolved
234
235
236
237
238
239
      $scope.updateTotal = function(value, valueOf){
        if(valueOf == 'v'){
          $scope.editdata.total = value * $scope.editdata.invoiced
        }else if(valueOf == 'i'){
          $scope.editdata.total = $scope.editdata.requestedVolume * value 
        }
a9aef0b1c   Anchit Jindal   new changes imple...
240
      }
e33b4556c   Kuldeep Arora   bugs resolved
241
242
243
244
245
246
247
248
  
      $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 
        }
      }                    
8d682e773   Mr. Hot Foods   changes in fuel o...
249

3c2c216d6   Kuldeep Arora   direct transactio...
250
     $scope.addFuelData = function() {
e33b4556c   Kuldeep Arora   bugs resolved
251
       $scope.showLoader = true;
8d682e773   Mr. Hot Foods   changes in fuel o...
252

e33b4556c   Kuldeep Arora   bugs resolved
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
        if ($scope.order.upliftDate != '') {
            $scope.order.upliftDate = new Date($scope.order.upliftDate);
            $scope.order.upliftDate = $scope.order.upliftDate.getTime();
          }
          if ($scope.order.departingDate != '') {
            $scope.order.departingDate = new Date($scope.order.departingDate);
            $scope.order.departingDate = $scope.order.departingDate.getTime();
          }
         // console.log($scope.order.quotePrice);
          var obj =JSON.parse($scope.order.priceQuote);
         // console.log('obj.papMargin',obj.papMargin);
          $scope.order.priceQuote = obj.papMargin;
  
          $scope.fuelData = {};
          $scope.fuelData.aircraftName = $scope.order.aircraftName 
          $scope.fuelData.companyName = $scope.order.companyName 
          $scope.fuelData.departingDate = $scope.order.departingDate 
          $scope.fuelData.fboCost = $scope.order.fboCost 
          $scope.fuelData.id = $scope.order.id 
          $scope.fuelData.invoiced = $scope.order.invoiced 
          $scope.fuelData.priceQuote = $scope.order.priceQuote 
          $scope.fuelData.volume = $scope.order.volume 
          $scope.fuelData.source = $scope.order.source 
          $scope.fuelData.status = $scope.order.status 
          $scope.fuelData.tierBreak = $scope.order.tierBreak 
          $scope.fuelData.total = $scope.order.total 
          $scope.fuelData.upliftDate = $scope.order.upliftDate 
          $scope.fuelData.companyId = $scope.selectedCompanyId;
            
a9aef0b1c   Anchit Jindal   new changes imple...
282
283
284
        
        
        $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
e33b4556c   Kuldeep Arora   bugs resolved
285
      //  console.log('$scope.order', $scope.dispatchOrder);
a9aef0b1c   Anchit Jindal   new changes imple...
286
        fuelOrdersService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
3c2c216d6   Kuldeep Arora   direct transactio...
287
288
289
          console.log("fuel data---",$scope.fuelData)
          console.log("oder data",$scope.dispatchOrder)
          console.log('result', result);
a9aef0b1c   Anchit Jindal   new changes imple...
290
291
292
293
294
295
296
297
298
299
          $scope.showLoader = false;
          $scope.order = {};
          $('#demo-modal-4').css('display', '');
          $scope.getOrders();
          toastr.success('Fuel Order Dispatched Successfully', {
                  closeButton: true
                })
        })
        
      }
8d682e773   Mr. Hot Foods   changes in fuel o...
300
      $scope.updateStatus = function(row, status) {
e33b4556c   Kuldeep Arora   bugs resolved
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
          $scope.showLoader = true;
          $scope.fuelData = {};
          $scope.fuelData.aircraftName = row.aircraftName 
          $scope.fuelData.companyName = row.companyName 
          $scope.fuelData.departingDate = row.departingDate 
          $scope.fuelData.fboCost = row.fboCost 
          $scope.fuelData.id = row.id 
          $scope.fuelData.invoiced = row.invoiced 
          $scope.fuelData.priceQuote = row.priceQuote 
          $scope.fuelData.volume = row.requestedVolume 
          $scope.fuelData.source = row.source 
          $scope.fuelData.status = status 
          $scope.fuelData.tierBreak = row.tierBreak 
          $scope.fuelData.total = row.total 
          $scope.fuelData.upliftDate = row.upliftDate 
8d682e773   Mr. Hot Foods   changes in fuel o...
316

5a7920053   Swarn Singh   selectbox color i...
317
318
        $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
        fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) {
e33b4556c   Kuldeep Arora   bugs resolved
319
         // console.log('result', result);
5a7920053   Swarn Singh   selectbox color i...
320
321
322
323
324
325
326
327
          $scope.showLoader = false;
          $scope.editdata = {};
          $('#demo-modal-5').css('display', '');
          $scope.getOrders();
          toastr.success('Fuel Order Updated Successfully', {
            closeButton: true
          });
      })
8d682e773   Mr. Hot Foods   changes in fuel o...
328

5a7920053   Swarn Singh   selectbox color i...
329
    }
8d682e773   Mr. Hot Foods   changes in fuel o...
330
331
  
        $scope.updateData = function() {
e33b4556c   Kuldeep Arora   bugs resolved
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
          $scope.showLoader = true;
          $scope.fuelData = {};
          $scope.fuelData.aircraftName = $scope.editdata.aircraftName 
          $scope.fuelData.companyName = $scope.editdata.companyName 
          $scope.fuelData.departingDate = $scope.editdata.departingDate 
          $scope.fuelData.fboCost = $scope.editdata.fboCost 
          $scope.fuelData.id = $scope.editdata.id 
          $scope.fuelData.invoiced = $scope.editdata.invoiced 
          $scope.fuelData.priceQuote = $scope.editdata.priceQuote 
          $scope.fuelData.volume = $scope.editdata.requestedVolume 
          $scope.fuelData.source = $scope.editdata.source 
          $scope.fuelData.status = $scope.editdata.status 
          $scope.fuelData.tierBreak = $scope.editdata.tierBreak 
          $scope.fuelData.total = $scope.editdata.total 
          $scope.fuelData.upliftDate = $scope.editdata.upliftDate 
a9aef0b1c   Anchit Jindal   new changes imple...
347
348
349
350
351
        
  
  
           $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
            fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) {
e33b4556c   Kuldeep Arora   bugs resolved
352
            //  console.log('result', result);
a9aef0b1c   Anchit Jindal   new changes imple...
353
354
355
356
357
358
359
360
361
              $scope.showLoader = false;
              $scope.editdata = {};
              $('#demo-modal-5').css('display', '');
              $scope.getOrders();
              toastr.success('Fuel Order Updated Successfully', {
                      closeButton: true
                    })
            })
          }
8d682e773   Mr. Hot Foods   changes in fuel o...
362
363
  
      $scope.getAircraft = function(company){
e33b4556c   Kuldeep Arora   bugs resolved
364

a9aef0b1c   Anchit Jindal   new changes imple...
365
        $scope.selectedCompanyName = company;
e33b4556c   Kuldeep Arora   bugs resolved
366
367
        //$scope.showLoader = true;
      //  console.log("id",company)
a9aef0b1c   Anchit Jindal   new changes imple...
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
        for (var i = 0; i < $scope.companyList.length; i++) {
          if ($scope.companyList[i].companyName == company) {
            if($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null){
              fuelOrdersService.getFuelCost($scope.companyList[i].id).then(function(margins) {
                $scope.marginList = margins;
                //console.log('$scope.marginList', $scope.marginList);
              })
            } else if ($scope.companyList[i].margin != null || $scope.companyList[i].marginAVGAS == null) {
              fuelOrdersService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) {
                $scope.marginList = margins;
                  })
            } else if ($scope.companyList[i].margin == null || $scope.companyList[i].marginAVGAS != null) {
              fuelOrdersService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) {
                    $scope.marginList = margins;
                  })
            }
            $scope.selectedCompanyId = $scope.companyList[i].id;
            $scope.marginId = $scope.companyList[i].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;
e33b4556c   Kuldeep Arora   bugs resolved
394
          //              $scope.showLoader = false;
a9aef0b1c   Anchit Jindal   new changes imple...
395
396
                    })
            }else{
e33b4556c   Kuldeep Arora   bugs resolved
397
            //  $scope.showLoader = false;
a9aef0b1c   Anchit Jindal   new changes imple...
398
399
400
401
402
            }
          }
        }
  
      }
8d682e773   Mr. Hot Foods   changes in fuel o...
403
       $scope.setCost = function(cost){
e33b4556c   Kuldeep Arora   bugs resolved
404
  	     // console.log(cost);
a9aef0b1c   Anchit Jindal   new changes imple...
405
406
407
408
409
410
  	      if(cost != null) {
  	        var obj =JSON.parse(cost);
  	        $scope.order.fboCost = obj.cost;
  	      }
  	        
  	    }
8d682e773   Mr. Hot Foods   changes in fuel o...
411
                              
6284a85b9   Jaideep Singh   fuel orders page ...
412

e33b4556c   Kuldeep Arora   bugs resolved
413
414
415
416
417
418
        $scope.cancelData = function() {
              $('#demo-modal-4').css('display', '');
        }
        $scope.canceleditdata = function() {
            $('#demo-modal-5').css('display', '');
      }
6284a85b9   Jaideep Singh   fuel orders page ...
419

dd378d69f   Mr. Hot Foods   changes in flight...
420
   
e33b4556c   Kuldeep Arora   bugs resolved
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
      	$scope.companyList = {};
  
                fuelOrdersService.getAllCompanies().then(function(result) {
                $scope.showLoader = true;
                $scope.companyList = result;
                $scope.showLoader = false;
              })
            
    /*Add a company services API used from customersService */
       getCompanyName();
      function getCompanyName(){
              CustomersService.getCompanyName().then(function(result) {
              $scope.showLoader = true;
              $scope.compNameList = result;
              //console.log("kd",result)
              $scope.showLoader = false;
            })
          }
       
       $scope.marginFilterOptions = [];
        CustomersService.getJetMargin($scope.userProfileId).then(function(result) {
          $scope.showLoader = true;
          $scope.jetMarginList = result;
          //console.log("jet margin",result,$scope.userProfileId)
          $scope.marginFilterOptions.push({
            'id': '', 'title': 'Show All'
          });
          for (var i = 0; i < result.length; i++) {
            $scope.marginFilterOptions.push({
              'id': result[i].id,
              'title': result[i].marginName
            })
          }
            $scope.showLoader = false;
        })
  
        CustomersService.getAvgMargin($scope.userProfileId).then(function(result) {
          $scope.avgsMarginList = result;
         // console.log('avgsMarginList',result)
        })
  
        $scope.showCompanyError = false;
        $scope.showMarginError = false;
  
        $scope.removeValidation = function(){
          $scope.showCompanyError = false;
            $('.companyNameInput').removeClass('customErrorInput');
            if($scope.data.companyName == 'undefined' || $scope.data.companyName == '') {
              $('.companyNameInput').addClass('customErrorInput');
              $scope.showCompanyError = true;
            }
        }
6284a85b9   Jaideep Singh   fuel orders page ...
473

e33b4556c   Kuldeep Arora   bugs resolved
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
        $scope.removeMarginValidation = function(){
          $scope.showMarginError = false;
            $('.marginSelectBox').removeClass('customErrorInput');
        }
  
        getData();
        function getData(){
        $scope.showLoader = true;
        CustomersService.getAircraftMake().then(function(result) {
          $scope.aircraftMakeList = result;
          $scope.showLoader = false;
        })
      }
      var companyData;
        $scope.addFirstData = function(sel, step){
a9aef0b1c   Anchit Jindal   new changes imple...
489
        $scope.showLoader = true;
e33b4556c   Kuldeep Arora   bugs resolved
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
          if($scope.data.companyName == undefined){
            $scope.showCompanyError = true;
            $('.companyNameInput').addClass('customErrorInput');
          }else if($scope.data.masterMargin == undefined){
            $scope.showMarginError = true;
            $('.marginSelectBox').addClass('customErrorInput');
          }else{
            $scope.aircraftDetails = [{ 
                    'tail':'',
                    'make': '',
                    'model': '',
                    'sizeId' : '',
                    'marginId': $scope.data.masterMargin,
                    'avgasMarginId': $scope.data.avgasMargin
                }];
              
            $(sel).trigger('next.m.' + step);
            getData();
          }
a9aef0b1c   Anchit Jindal   new changes imple...
509
        $scope.showLoader = false;
e33b4556c   Kuldeep Arora   bugs resolved
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
        }
          $scope.addNew = function(){
        $scope.showLoader = true;
              $scope.aircraftDetails.push({ 
                  'tail':'',
                'make': '',
                'model': '',
                'sizeId' : '',
                'marginId': $scope.data.masterMargin,
                'avgasMarginId': $scope.data.avgasMargin
              });
        $scope.showLoader = false;
          };
  
      $scope.aircraft = {};
       $scope.getModal = function(makeId, index){
            $scope.showLoader = true;
          //console.log(makeId)
          $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];
            })
          }
  
          $scope.getSize = function(model, index){
            $scope.showLoader = true;
            CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) {
              $scope.showLoader = false;
                $scope.aircraftDetails[index].aircraftSizeList = result;
              //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0];
            })
          }
  
       $scope.aircraftListData = {};
          $scope.addData = [];
          $scope.saveCompanyData = function(){
            CustomersService.addCompany($scope.data).then(function(result) {
                $scope.accountId = result;
              $scope.aircraft.accountId = $scope.accountId;
              
              for(var i=0; i<$scope.aircraftDetails.length;i++){
                  $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
                    });
                }
                $scope.aircraftListData.aircraftList = $scope.addData;
                $scope.aircraftListData.accountId = $scope.aircraft.accountId;
                
                if($scope.aircraftListData.aircraftList[0].tail == "" || $scope.aircraftListData.aircraftList[0].make == null || $scope.aircraftListData.aircraftList[0].model == null){
                  $scope.aircraftListData.aircraftList = [];
                }
                
                CustomersService.addAircraft($scope.aircraftListData).then(function(result) {
  
                  if(result != null && result.success){
                    toastr.success(''+result.success+'', {
                        closeButton: true
                      })
                      $('#demo-modal-3').modal('hide');
                      getAllCompanies();
                  }else{
                    toastr.error(''+result.statusText+'', {
                        closeButton: true
                      })
                  }
                });
                
              })
            
            
          }
  
          $scope.checkJetWithTail = function(tail, index){
  
            //console.log("tail==============",tail, index)
            ViewCompanyService.checkJetType(tail).then(function(result) {
              //console.log("result",result)
              if(result.jetA == "true"){
                $scope.jetShow[index] = false;
                $scope.marginShow[index] = true;
              }else{
                $scope.jetShow[index] = true;
                $scope.marginShow[index] = false;
              }
            })
          }
4bb02bb84   Rishav   new integration w...
604

6284a85b9   Jaideep Singh   fuel orders page ...
605
    $scope.sourceList = [{source:"Direct Jet-A"},{source:"Direct AVGAS 100LL"}];
4bb02bb84   Rishav   new integration w...
606

6284a85b9   Jaideep Singh   fuel orders page ...
607
608
609
    $scope.data = {};
    
   
4bb02bb84   Rishav   new integration w...
610

6284a85b9   Jaideep Singh   fuel orders page ...
611
     }