Blame view

app/partials/flightDepDashboard/flightDepDashboard.controller.js 3.8 KB
da04b5b2f   Mr. Hot Foods   flight Dep
1
2
3
4
      (function() {
      'use strict'
      
      angular.module('acufuel')
f746aee1b   Anchit Jindal   account settingsc...
5
          .controller('flightDepDashboardController', [ '$scope', '$filter', '$rootScope', '$state', 'flightDepDashboardService', flightDepDashboardController]);
da04b5b2f   Mr. Hot Foods   flight Dep
6
7
8
9
          
      function flightDepDashboardController($scope, $filter, $rootScope, $state, flightDepDashboardService) {
          $scope.getQuote = true;
          $scope.showQuote = false;
25082c4e3   Anchit Jindal   flight dept order...
10
11
          
          $scope.order = {};
1b71872b2   Kuldeep Arora   email and code be...
12
13
14
15
          $scope.dispatchOrder = {};
          $scope.dispatchOrder.fuelOrderList = [];
          $scope.order.upliftDate = '';
          $scope.order.departingDate = '';
25082c4e3   Anchit Jindal   flight dept order...
16
          
a9aef0b1c   Anchit Jindal   new changes imple...
17
          $scope.fboList =[];
f746aee1b   Anchit Jindal   account settingsc...
18
          getAircraftList();
da04b5b2f   Mr. Hot Foods   flight Dep
19
          $scope.getQuote = function () {
1b71872b2   Kuldeep Arora   email and code be...
20
              $scope.getQuote = false;
da04b5b2f   Mr. Hot Foods   flight Dep
21
              $scope.showQuote = true;
1b71872b2   Kuldeep Arora   email and code be...
22
          }
da04b5b2f   Mr. Hot Foods   flight Dep
23

1b71872b2   Kuldeep Arora   email and code be...
24
          $scope.logout = function () {
f62f8940f   Kuldeep Arora   UI changes
25
              localStorage.clear();
1b71872b2   Kuldeep Arora   email and code be...
26
27
28
29
30
              localStorage.removeItem("loginStatus");
              $rootScope.path = false;
              $state.reload();
          }
          $scope.getFBOMarginList = function () {
1b71872b2   Kuldeep Arora   email and code be...
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
              flightDepDashboardService.getFBOs($scope.order.airport).then(function(result) {
                $scope.marginList = result;
              })
          }
          
          $scope.aircraftList = [];
          function getAircraftList() {
              flightDepDashboardService.getAircrafts().then(function(result) {
                $scope.aircraftList = result;
              })
          }
          
          $scope.getTiers = function() {
              var temp = JSON.parse($scope.order.priceQuote);
              if(temp != null) {
                  flightDepDashboardService.getTiers(temp.owner.id).then(function(result) {
                      if(result != null){
                          $scope.tierList = result;
                      } else {
                          $scope.tierList = [];
                          $scope.tierList.push({
                              'minTierBreak': '0', 'maxTierBreak': '∞'
                          });
                      }
                  })
              }
f746aee1b   Anchit Jindal   account settingsc...
57
          }
da04b5b2f   Mr. Hot Foods   flight Dep
58

1b71872b2   Kuldeep Arora   email and code be...
59
60
61
          $scope.setCost = function(cost){
              if(cost != null) {
                  var obj =JSON.parse(cost);
f62f8940f   Kuldeep Arora   UI changes
62
                 // console.log('costttttt',obj.cost);
1b71872b2   Kuldeep Arora   email and code be...
63
64
65
66
67
68
69
                  $scope.order.fboCost = obj.cost;
              }
          }
          
          $scope.cancelOrder = function() {
              $scope.order = {};
              $scope.getQuote = true;
25082c4e3   Anchit Jindal   flight dept order...
70
              $scope.showQuote = false;
1b71872b2   Kuldeep Arora   email and code be...
71
72
73
74
75
76
77
78
79
80
81
82
83
          }
          
          $scope.dispatchFuel = function(){
              $scope.showLoader = true;
              $scope.order.companyId = $scope.selectedCompanyId;
              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();
              }
da04b5b2f   Mr. Hot Foods   flight Dep
84

1b71872b2   Kuldeep Arora   email and code be...
85
86
87
88
89
90
91
92
93
94
95
96
97
98
              $scope.order.status = 'pending';
              
              console.log($scope.order.quotePrice);
              var obj =JSON.parse($scope.order.priceQuote);
              console.log('obj.papMargin',obj.papMargin);
              $scope.order.priceQuote = obj.papMargin;
              $scope.order.fboOwnerId = obj.owner.id;
              $scope.dispatchOrder.fuelOrderList.push($scope.order);
              console.log('$scope.order', $scope.dispatchOrder);
              flightDepDashboardService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
                  console.log('result', result);
                  $scope.showLoader = false;
                  $scope.order = {};
                  toastr.success('Fuel Order Dispatched Successfully', {
da04b5b2f   Mr. Hot Foods   flight Dep
99
100
                    closeButton: true
                  })
1b71872b2   Kuldeep Arora   email and code be...
101
102
              })
          }
da04b5b2f   Mr. Hot Foods   flight Dep
103
104
      }
  })();