Blame view

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

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

e33b4556c   Kuldeep Arora   bugs resolved
7
8
        $scope.showFuelOrderModal = false;
        $scope.optionSelected;
ffe62a0ef   Kuldeep Arora   time field displa...
9
        $scope.orderdata = {};
e33b4556c   Kuldeep Arora   bugs resolved
10
11
12
13
14
15
        $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
        $scope.data = {};
        $scope.order = {};
        $scope.dispatchOrder = {};
1b71872b2   Kuldeep Arora   email and code be...
20
        $scope.dispatchOrder.fuelOrderList = [];
a55afb325   Kuldeep Arora   reconciled order ...
21
        $scope.defaultStatus = '';
e33b4556c   Kuldeep Arora   bugs resolved
22
23
        $scope.statusFilterOptions = [];
        $scope.statusFilterOptions.push({
1b71872b2   Kuldeep Arora   email and code be...
24
25
26
27
28
29
30
31
32
33
34
35
          'id': '', 'title': 'Show All'
        },{
          'id': 'pending', 'title': 'Pending'
        },{
          'id': 'invoiced', 'title': 'Invoiced'
        },{
          'id': 'paid', 'title': 'Paid'
        },{
          'id': 'cancelled', 'title': 'Cancelled'
        },{
          'id': 'archived', 'title': 'Archived'
        }
8d682e773   Mr. Hot Foods   changes in fuel o...
36
37
       
        );
a55afb325   Kuldeep Arora   reconciled order ...
38
39
40
        if($stateParams.status =="paid"){
          $scope.defaultStatus = "paid";
        }
e33b4556c   Kuldeep Arora   bugs resolved
41
42
43
44
        getAllCompanies();
  
      function getAllCompanies(){
        fuelOrdersService.getAllCompanies().then(function(result) {
e33b4556c   Kuldeep Arora   bugs resolved
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
77
78
          $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...
79
80
81
82
      function colourFunction() {
        var myselect = document.getElementById('colorfulSelectbox'),
        colour = myselect.options[myselect.selectedIndex].className;
        myselect.style.background = colour;
5a7920053   Swarn Singh   selectbox color i...
83
84
        myselect.blur();
      }
d00b696ca   Anchit Jindal   minor changes
85
      
5a7920053   Swarn Singh   selectbox color i...
86

d00b696ca   Anchit Jindal   minor changes
87
88
89
      /*setInterval(function(){
        colourFunction();
      }, 1)*/
5a7920053   Swarn Singh   selectbox color i...
90

8d682e773   Mr. Hot Foods   changes in fuel o...
91
92
93
  
        $scope.attachmentFilterOptions = [];
      $scope.attachmentFilterOptions.push({
1b71872b2   Kuldeep Arora   email and code be...
94
95
96
97
98
99
          'id': '', 'title': 'Show All'
        },{
          'id': '!null', 'title': 'Attachments'
        },{
          'id': 'null', 'title': 'No Attachments'
        }
8d682e773   Mr. Hot Foods   changes in fuel o...
100
       );
9aae3d136   Mr. Hot Foods   show loaders and ...
101

f100849ce   Mr. Hot Foods   analytics updates
102
103
104
105
106
        //  $(document).ready(function() {
        //     $scope.showLoader = true;
        //       $('#example').DataTable();
        //       $scope.showLoader = false;
        //   });
6284a85b9   Jaideep Singh   fuel orders page ...
107
       
8d682e773   Mr. Hot Foods   changes in fuel o...
108
       $scope.getOrders = function() {
6284a85b9   Jaideep Singh   fuel orders page ...
109
110
            fuelOrdersService.getOrders().then(function(result) {
              $scope.orderdata = result;
7e0d0bdd5   Kuldeep Arora   update fuel order UI
111
              for(var i=0 ; i < $scope.orderdata.length ; i++){
8d682e773   Mr. Hot Foods   changes in fuel o...
112
                  $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate);
7e0d0bdd5   Kuldeep Arora   update fuel order UI
113
                  $scope.orderdata[i].departingDateS = new Date($scope.orderdata[i].departingDate);
20f645d6f   Kuldeep Arora   fuelorder
114
                  $scope.orderdata[i].fuelingDate = new Date($scope.orderdata[i].fuelingDate);
6284a85b9   Jaideep Singh   fuel orders page ...
115

7e0d0bdd5   Kuldeep Arora   update fuel order UI
116
117
                  var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear();
                  var departingStr = "" + ($scope.orderdata[i].departingDateS.getMonth() + 1) + "/" + $scope.orderdata[i].departingDateS.getDate() + "/" + $scope.orderdata[i].departingDateS.getFullYear();
a9b337557   Kuldeep Arora   fuelingdate order
118
                //  var fuelingDateStr = "" + ($scope.orderdata[i].fuelingDate.getMonth() + 1) + "/" + $scope.orderdata[i].fuelingDate.getDate() + "/" + $scope.orderdata[i].fuelingDate.getFullYear();
7e0d0bdd5   Kuldeep Arora   update fuel order UI
119
120
                  $scope.orderdata[i].upliftDateString = str;
                  $scope.orderdata[i].departingDateString = departingStr;
a9b337557   Kuldeep Arora   fuelingdate order
121
122
                 // $scope.orderdata[i].fuelingDate = fuelingDateStr;
                 
ffe62a0ef   Kuldeep Arora   time field displa...
123
                  
6284a85b9   Jaideep Singh   fuel orders page ...
124
              }
6d8b1f26c   Kuldeep Arora   minor
125
            //  console.log("==result===",$scope.orderdata)
6284a85b9   Jaideep Singh   fuel orders page ...
126
127
128
             
               $scope.displayFuelOrderList = new NgTableParams({
                page: 1,
a9b337557   Kuldeep Arora   fuelingdate order
129
                count: 50,
6284a85b9   Jaideep Singh   fuel orders page ...
130
131
132
              }, {
                data: $scope.orderdata
              });
5a7920053   Swarn Singh   selectbox color i...
133
              $(document).ready(function(){
d00b696ca   Anchit Jindal   minor changes
134
              	function changeSelectboxBg(){
5fe941ac6   Kuldeep Arora   update fuel
135
                  setInterval(function(){
6c5a99488   Kuldeep Arora   analytics and fue...
136
                    if ($('.table select').is(':focus')) {
5fe941ac6   Kuldeep Arora   update fuel
137

6c5a99488   Kuldeep Arora   analytics and fue...
138
139
                    }else{
              		    var myselect = document.getElementsByClassName('colorfulSelectbox');
d00b696ca   Anchit Jindal   minor changes
140
141
142
143
  
                      for (var i = 0; i < myselect.length; i++) {
                        var colourIndex = $(myselect[i]).prop('selectedIndex');
                        colourIndex = colourIndex + 1;
d00b696ca   Anchit Jindal   minor changes
144
145
                        var getColor = $('.colorfulSelectbox option:nth-child('+colourIndex+')').css('color');
                        $(myselect[i]).css('background-color', getColor);
d00b696ca   Anchit Jindal   minor changes
146
147
                        myselect[i].blur();
                      }
6c5a99488   Kuldeep Arora   analytics and fue...
148
                    }
5fe941ac6   Kuldeep Arora   update fuel
149
                  }, 1000)
d00b696ca   Anchit Jindal   minor changes
150
151
              	}
              	changeSelectboxBg();
6d8b1f26c   Kuldeep Arora   minor
152
               // console.log("=====$scope.displayFuelOrderList====",$scope.displayFuelOrderList)
d00b696ca   Anchit Jindal   minor changes
153
                
5fe941ac6   Kuldeep Arora   update fuel
154
                /*$('.pagination , .recordCountSelect').click(function(){
d00b696ca   Anchit Jindal   minor changes
155
156
              	  changeSelectboxBg();
                })
5fe941ac6   Kuldeep Arora   update fuel
157
158
159
160
                $('.input-filter').keydown(function(){
                  console.log('function..........');
                  changeSelectboxBg();
                })*/
5a7920053   Swarn Singh   selectbox color i...
161
              })
6284a85b9   Jaideep Singh   fuel orders page ...
162
            })
8d682e773   Mr. Hot Foods   changes in fuel o...
163
164
165
       }
       
       $scope.getOrders();
3c2c216d6   Kuldeep Arora   direct transactio...
166
       $scope.optionSelected='';
8d682e773   Mr. Hot Foods   changes in fuel o...
167
168
       $scope.onFWSelect = function() {
                          if($scope.optionSelected == 'dt'){
3c2c216d6   Kuldeep Arora   direct transactio...
169
170
                            $('#demo-modal-4').css('display', 'block');
                             $scope.optionSelected='';
8d682e773   Mr. Hot Foods   changes in fuel o...
171
172
                        }
                        if($scope.optionSelected == 'efo'){
1b71872b2   Kuldeep Arora   email and code be...
173
                            $scope.showLoader = true;
8d682e773   Mr. Hot Foods   changes in fuel o...
174
175
176
177
178
179
180
181
182
183
                              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...
184
                                    $scope.optionSelected='';
8d682e773   Mr. Hot Foods   changes in fuel o...
185
186
187
                              })
                          }
                      }
e33b4556c   Kuldeep Arora   bugs resolved
188
       $scope.attachmentrowid = ""
dd378d69f   Mr. Hot Foods   changes in flight...
189

e33b4556c   Kuldeep Arora   bugs resolved
190
191
       
       $scope.attachment = function(id, value, url) {
1b71872b2   Kuldeep Arora   email and code be...
192
          $scope.attachmentrowid = id
1b71872b2   Kuldeep Arora   email and code be...
193
194
195
196
197
198
199
200
201
          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');
          }
      }
e33b4556c   Kuldeep Arora   bugs resolved
202
203
204
205
  
      $scope.cancelDeleteAttachment = function() {
            $('#delete1').css('display', '');
      }
c277275bb   Mr. Hot Foods   login changes
206

e33b4556c   Kuldeep Arora   bugs resolved
207
208
209
      $scope.deleteAttachment = function() {
        $scope.showLoader = true;
        fuelOrdersService.deleteAttachment($scope.attachmentrowid).then(function(result) {
a9aef0b1c   Anchit Jindal   new changes imple...
210

e33b4556c   Kuldeep Arora   bugs resolved
211
212
213
214
215
216
217
218
219
                if(result.success){
                toastr.success(''+result.success+'', {
                          closeButton: true
                      })
                }
            })
            $scope.showLoader = false;
            $('#delete1').css('display', '');
      }
c277275bb   Mr. Hot Foods   login changes
220

dd378d69f   Mr. Hot Foods   changes in flight...
221
     $scope.saveUploadAttachment = function(attachmentData) {
9aae3d136   Mr. Hot Foods   show loaders and ...
222
       $scope.showLoader = true;
1b71872b2   Kuldeep Arora   email and code be...
223
224
225
        $scope.data.media = attachmentData
        $scope.data.id = $scope.attachmentrowid
      fuelOrdersService.uploadAttachment($scope.data).then(function(result) {
a9aef0b1c   Anchit Jindal   new changes imple...
226
              if(result){
a9aef0b1c   Anchit Jindal   new changes imple...
227
228
229
230
231
232
233
234
235
                    toastr.success(''+"Upload Successful"+'', {
                              closeButton: true
                          })
                    }
                    
              })
                $scope.showLoader = false;
                $('#demo-modal-6').css('display', 'none');
          }
dd378d69f   Mr. Hot Foods   changes in flight...
236

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

e33b4556c   Kuldeep Arora   bugs resolved
241
242
      $scope.editdata = {};
      
8d682e773   Mr. Hot Foods   changes in fuel o...
243

e33b4556c   Kuldeep Arora   bugs resolved
244
      $scope.editTableRow = function(rowData){
f5c86d6b8   Kuldeep Arora   minor update
245
       //console.log('row data', rowData);
e33b4556c   Kuldeep Arora   bugs resolved
246
247
        $scope.editdata = rowData;
        $('#demo-modal-5').css('display', 'block');
a9aef0b1c   Anchit Jindal   new changes imple...
248
      }
8d682e773   Mr. Hot Foods   changes in fuel o...
249

e33b4556c   Kuldeep Arora   bugs resolved
250
251
252
253
254
255
      $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...
256
      }
e33b4556c   Kuldeep Arora   bugs resolved
257

60b62c053   Kuldeep Arora   redesign of direc...
258
259
260
261
262
263
264
      $scope.setCost = function(cost){
          if(cost != null) {
            var obj =JSON.parse(cost);
            $scope.order.fboCost = obj.cost;
          }
            
        }
d1e8d9afb   Kuldeep Arora   fuel order & home...
265
266
267
      $scope.addTotal = function(value, valueOf) {
      if (value != undefined && valueOf != undefined) {
        value = JSON.parse(value)
39a850f31   Kuldeep Arora   total calculation
268
        $scope.order.total = Math.abs(value.papTotal) * valueOf; 
d1e8d9afb   Kuldeep Arora   fuel order & home...
269
270
      }
    }                
8d682e773   Mr. Hot Foods   changes in fuel o...
271

3c2c216d6   Kuldeep Arora   direct transactio...
272
     $scope.addFuelData = function() {
a55afb325   Kuldeep Arora   reconciled order ...
273
              $scope.showLoader = true;
60b62c053   Kuldeep Arora   redesign of direc...
274
275
276
277
278
279
280
281
              $scope.fuelData = {};
              $scope.fuelData.companyId = $scope.selectedCompanyId;
  
              $scope.fuelData.companyName = $scope.order.companyName; 
              var aircraftObj =JSON.parse($scope.order.aircraftName);
              $scope.fuelData.aircraftName = aircraftObj.tail;
              $scope.fuelData.make = aircraftObj.make;
              $scope.fuelData.model = aircraftObj.model;
20f645d6f   Kuldeep Arora   fuelorder
282
             // $scope.fuelData.fuelOn = $scope.order.fuelOn;
60b62c053   Kuldeep Arora   redesign of direc...
283
284
              $scope.fuelData.invoiced = $scope.order.invoiced;
              $scope.fuelData.volume = $scope.order.volume; 
0173d74ad   Kuldeep Arora   source autopopula...
285
             // $scope.fuelData.source = $scope.order.source; 
084c4873b   Kuldeep Arora   validation for re...
286
             
60b62c053   Kuldeep Arora   redesign of direc...
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
              $scope.fuelData.total = $scope.order.total;
              //tier no use
              $scope.fuelData.tierBreak = $scope.order.tierBreak;
  
              var obj =JSON.parse($scope.order.priceQuote);
              $scope.fuelData.priceQuote = obj.papTotal;
              $scope.fuelData.fboCost = obj.cost;
              $scope.fuelData.productName = obj.productName;
  
              $scope.fuelData.etaTime = $scope.order.etaTime;
              $scope.fuelData.etdTime = $scope.order.etdTime;
              $scope.fuelData.certificateType = $scope.order.certificateType;
              var currentDate = new Date();
              var hours = currentDate.getHours();
              var min = currentDate.getMinutes();
              var sec = currentDate.getSeconds();
              if ($scope.order.upliftDate != '') {
                      $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec;
                $scope.order.upliftDate = new Date($scope.order.upliftDate);
                $scope.fuelData.upliftDate = $scope.order.upliftDate.getTime();
              }
676250262   Kuldeep Arora   enhancement fuel ...
308

60b62c053   Kuldeep Arora   redesign of direc...
309
310
311
312
313
314
315
               
              if ($scope.order.departingDate != '') {
                $scope.order.departingDate = $scope.order.departingDate + ' ' + hours + ':' + min + ':' + sec;
                $scope.order.departingDate = new Date($scope.order.departingDate);
                $scope.fuelData.departingDate = $scope.order.departingDate.getTime();
              }
                
084c4873b   Kuldeep Arora   validation for re...
316
317
318
319
320
321
322
323
              if($scope.order.status === null || $scope.order.status === undefined){
  
                  $scope.fuelData.status = "pending"; //default status
  
                }else {
                  
                   $scope.fuelData.status = $scope.order.status;
                } 
20f645d6f   Kuldeep Arora   fuelorder
324
325
326
327
328
329
  
                if($scope.fuelData.fuelOn === null || $scope.fuelData.fuelOn ===undefined){
                    $scope.fuelData.fuelOn = "Arrival"; //default fuelon
                  }else {
                    $scope.fuelData.fuelOn = $scope.order.fuelOn ;
                  }
0173d74ad   Kuldeep Arora   source autopopula...
330
331
              
              if($scope.baseTenant && $scope.contractFuelVendor ){
6c795a9f9   Kuldeep Arora   tenant/caa status...
332
                  $scope.fuelData.source = "Tenant/CAA" ;
0173d74ad   Kuldeep Arora   source autopopula...
333
334
335
336
337
338
                }else if($scope.baseTenant)
                {
                  $scope.fuelData.source = "Tenant/Base Customer";
                }else if($scope.contractFuelVendor){
                  $scope.fuelData.source = "CAA Member";
                }
084c4873b   Kuldeep Arora   validation for re...
339
              $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
0173d74ad   Kuldeep Arora   source autopopula...
340
            //  console.log("=====$scope.fueldata======",$scope.fuelData)
084c4873b   Kuldeep Arora   validation for re...
341
342
343
344
              fuelOrdersService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
                  $scope.showLoader = false;
                  $scope.order = {};
                  $scope.dispatchOrder.fuelOrderList = [];
bb8754ed9   Kuldeep Arora   pagination fuel t...
345
346
347
                  $scope.fuelData.source='';
                  $scope.baseTenant=false;
                  $scope.contractFuelVendor=false;
084c4873b   Kuldeep Arora   validation for re...
348
349
350
351
352
                  $('#demo-modal-4').css('display', '');
                  $scope.getOrders();
                  toastr.success('Fuel Order Dispatched Successfully', {
                          closeButton: true
                        })
60b62c053   Kuldeep Arora   redesign of direc...
353
            }) 
676250262   Kuldeep Arora   enhancement fuel ...
354

60b62c053   Kuldeep Arora   redesign of direc...
355
                 
a9aef0b1c   Anchit Jindal   new changes imple...
356
      }
60b62c053   Kuldeep Arora   redesign of direc...
357

8d682e773   Mr. Hot Foods   changes in fuel o...
358
      $scope.updateStatus = function(row, status) {
a55afb325   Kuldeep Arora   reconciled order ...
359

e33b4556c   Kuldeep Arora   bugs resolved
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
          $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...
375

5a7920053   Swarn Singh   selectbox color i...
376
377
        $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
        fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) {
5a7920053   Swarn Singh   selectbox color i...
378
379
          $scope.showLoader = false;
          $scope.editdata = {};
9d840540f   Anchit Jindal   fixed bugs and ne...
380
381
          $scope.fuelData = {};
          $scope.dispatchOrder.fuelOrderList = [];
5a7920053   Swarn Singh   selectbox color i...
382
383
384
385
386
387
          $('#demo-modal-5').css('display', '');
          $scope.getOrders();
          toastr.success('Fuel Order Updated Successfully', {
            closeButton: true
          });
      })
8d682e773   Mr. Hot Foods   changes in fuel o...
388

5a7920053   Swarn Singh   selectbox color i...
389
    }
ffe62a0ef   Kuldeep Arora   time field displa...
390
        $scope.fuelData = {}; 
8d682e773   Mr. Hot Foods   changes in fuel o...
391
        $scope.updateData = function() {
ffe62a0ef   Kuldeep Arora   time field displa...
392
            if($scope.editdata.etaTime != null && $scope.editdata.etdTime != null){
731e27f5e   Kuldeep Arora   fuel order ui
393
394
395
396
397
398
399
400
401
402
403
404
                          $scope.showLoader = true;
                          $scope.fuelData.aircraftName = $scope.editdata.aircraftName; 
                          $scope.fuelData.companyName = $scope.editdata.companyName;
                          $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; 
197a45df0   Kuldeep Arora   departing date fix
405
406
407
408
409
410
  
                          var currentDate = new Date();
                          var hours = currentDate.getHours();
                          var min = currentDate.getMinutes();
                          var sec = currentDate.getSeconds();
                          $scope.editdata.upliftDateString = $scope.editdata.upliftDateString + ' ' + hours + ':' + min + ':' + sec;
731e27f5e   Kuldeep Arora   fuel order ui
411
412
                          $scope.editdata.upliftDateString = new Date($scope.editdata.upliftDateString);
                          $scope.editdata.upliftDateString = $scope.editdata.upliftDateString.getTime();
197a45df0   Kuldeep Arora   departing date fix
413
                          $scope.editdata.departingDateString = $scope.editdata.departingDateString + ' ' + hours + ':' + min + ':' + sec;
731e27f5e   Kuldeep Arora   fuel order ui
414
415
416
417
418
419
420
421
422
423
424
                          $scope.editdata.departingDateString = new Date($scope.editdata.departingDateString);
                          $scope.editdata.departingDateString = $scope.editdata.departingDateString.getTime();
                        
                          $scope.fuelData.upliftDate = $scope.editdata.upliftDateString; 
                          $scope.fuelData.departingDate = $scope.editdata.departingDateString; 
                          $scope.fuelData.productName = $scope.editdata.productName;
                          /*$scope.fuelData.etaTime = $scope.editdata.etaTime.toLocaleTimeString();
                          $scope.fuelData.etdTime = $scope.editdata.etdTime.toLocaleTimeString();*/
                          $scope.fuelData.etaTime = $scope.editdata.etaTime;
                          $scope.fuelData.etdTime = $scope.editdata.etdTime;
                          $scope.fuelData.certificateType = $scope.editdata.certificateType;
20f645d6f   Kuldeep Arora   fuelorder
425
426
427
428
429
430
                         // $scope.fuelData.fuelOn = $scope.editdata.fuelOn;
                          if($scope.fuelData.fuelOn === null || $scope.fuelData.fuelOn ===undefined){
                            $scope.fuelData.fuelOn = "Arrival"; //default fuelon
                          }else {
                            $scope.fuelData.fuelOn = $scope.editdata.fuelOn ;
                          }
731e27f5e   Kuldeep Arora   fuel order ui
431
                          $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
731e27f5e   Kuldeep Arora   fuel order ui
432
                        fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) {
731e27f5e   Kuldeep Arora   fuel order ui
433
434
435
436
437
438
439
                          $scope.showLoader = false;
                          $scope.editdata = {};
                          $('#demo-modal-5').css('display', '');
                          $scope.getOrders();
                          toastr.success('Fuel Order Updated Successfully', {
                                  closeButton: true
                                })
7e0d0bdd5   Kuldeep Arora   update fuel order UI
440
                        })
731e27f5e   Kuldeep Arora   fuel order ui
441
                   
20f645d6f   Kuldeep Arora   fuelorder
442
                          
731e27f5e   Kuldeep Arora   fuel order ui
443
               
7e0d0bdd5   Kuldeep Arora   update fuel order UI
444
445
446
447
448
449
450
            }else
              {
                toastr.error('Please select Arrival Time and Departure time both.', {
                        closeButton: true
                      })     
              }
          
a9aef0b1c   Anchit Jindal   new changes imple...
451
          }
8d682e773   Mr. Hot Foods   changes in fuel o...
452
453
  
      $scope.getAircraft = function(company){
e33b4556c   Kuldeep Arora   bugs resolved
454

a9aef0b1c   Anchit Jindal   new changes imple...
455
        $scope.selectedCompanyName = company;
e33b4556c   Kuldeep Arora   bugs resolved
456
        //$scope.showLoader = true;
a9aef0b1c   Anchit Jindal   new changes imple...
457
458
        for (var i = 0; i < $scope.companyList.length; i++) {
          if ($scope.companyList[i].companyName == company) {
0173d74ad   Kuldeep Arora   source autopopula...
459
460
461
462
              $scope.order.certificateType = $scope.companyList[i].certificateType;
              $scope.baseTenant = $scope.companyList[i].baseTenant;
              $scope.contractFuelVendor = $scope.companyList[i].contractFuelVendor;
              $scope.fuelerlinxCustomer = $scope.companyList[i].fuelerlinxCustomer;
a9aef0b1c   Anchit Jindal   new changes imple...
463
464
465
            if($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null){
              fuelOrdersService.getFuelCost($scope.companyList[i].id).then(function(margins) {
                $scope.marginList = margins;
a9aef0b1c   Anchit Jindal   new changes imple...
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
              })
            } 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
486
          //              $scope.showLoader = false;
a9aef0b1c   Anchit Jindal   new changes imple...
487
488
                    })
            }else{
e33b4556c   Kuldeep Arora   bugs resolved
489
            //  $scope.showLoader = false;
a9aef0b1c   Anchit Jindal   new changes imple...
490
491
492
493
494
            }
          }
        }
  
      }
60b62c053   Kuldeep Arora   redesign of direc...
495
       
8d682e773   Mr. Hot Foods   changes in fuel o...
496
                              
6284a85b9   Jaideep Singh   fuel orders page ...
497

e33b4556c   Kuldeep Arora   bugs resolved
498
499
500
501
502
503
        $scope.cancelData = function() {
              $('#demo-modal-4').css('display', '');
        }
        $scope.canceleditdata = function() {
            $('#demo-modal-5').css('display', '');
      }
6284a85b9   Jaideep Singh   fuel orders page ...
504

dd378d69f   Mr. Hot Foods   changes in flight...
505
   
1b71872b2   Kuldeep Arora   email and code be...
506
        $scope.companyList = {};
e33b4556c   Kuldeep Arora   bugs resolved
507
508
509
510
511
512
513
514
515
516
517
518
519
  
                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;
e33b4556c   Kuldeep Arora   bugs resolved
520
521
522
523
524
525
526
527
              $scope.showLoader = false;
            })
          }
       
       $scope.marginFilterOptions = [];
        CustomersService.getJetMargin($scope.userProfileId).then(function(result) {
          $scope.showLoader = true;
          $scope.jetMarginList = result;
e33b4556c   Kuldeep Arora   bugs resolved
528
529
530
531
532
533
534
535
536
537
538
539
540
541
          $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;
e33b4556c   Kuldeep Arora   bugs resolved
542
543
544
545
546
547
548
549
550
551
552
553
554
        })
  
        $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 ...
555

e33b4556c   Kuldeep Arora   bugs resolved
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
        $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...
571
        $scope.showLoader = true;
e33b4556c   Kuldeep Arora   bugs resolved
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
          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...
591
        $scope.showLoader = false;
e33b4556c   Kuldeep Arora   bugs resolved
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
        }
          $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;
e33b4556c   Kuldeep Arora   bugs resolved
609
          $scope.aircraft.make = makeId;
e33b4556c   Kuldeep Arora   bugs resolved
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
            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 = [];
60b62c053   Kuldeep Arora   redesign of direc...
628

e33b4556c   Kuldeep Arora   bugs resolved
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
          $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){
e33b4556c   Kuldeep Arora   bugs resolved
672
            ViewCompanyService.checkJetType(tail).then(function(result) {
e33b4556c   Kuldeep Arora   bugs resolved
673
674
675
676
677
678
679
680
681
              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...
682

ffe62a0ef   Kuldeep Arora   time field displa...
683
684
     $scope.etaTimeList=[];
     $scope.etdTimeList =[];
7e0d0bdd5   Kuldeep Arora   update fuel order UI
685

6284a85b9   Jaideep Singh   fuel orders page ...
686
    $scope.sourceList = [{source:"Direct Jet-A"},{source:"Direct AVGAS 100LL"}];
731e27f5e   Kuldeep Arora   fuel order ui
687
688
689
690
691
692
    $scope.etaTimeList  = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"},
                        {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"},
                        {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"},
                        {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"},
                        {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"},
                        {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},];
7e0d0bdd5   Kuldeep Arora   update fuel order UI
693
694
695
696
697
698
  
    $scope.etdTimeList  = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"},
                        {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"},
                        {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"},
                        {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"},
                        {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"},
731e27f5e   Kuldeep Arora   fuel order ui
699
                        {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},];
4bb02bb84   Rishav   new integration w...
700

6284a85b9   Jaideep Singh   fuel orders page ...
701
702
703
    $scope.data = {};
    
   
4bb02bb84   Rishav   new integration w...
704

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