Blame view

app/partials/updateFuelManager/updateFuelManager.controller.js 6.61 KB
feacde5ff   Rishav   setup acuefuel in...
1
2
3
4
5
  
  'use strict';
  
   //Load controller
    angular.module('acufuel')
feacde5ff   Rishav   setup acuefuel in...
6

1097c2ce1   Swarn Singh   margin module add...
7
8
        .controller('updateFuelManagerController', ['$scope','$uibModal', 'updateFuelManagerService', function($scope , $uibModal, updateFuelManagerService) {
  		
4bb02bb84   Rishav   new integration w...
9
10
11
12
13
14
15
16
17
          $scope.yes = function(data){
              console.log('========');
              console.log('value', data);
              $uibModal.yes({
                  templateUrl: 'partials/pricingcontact/pricingcontact.html',
                  backdrop: true,
                  scope: $scope,
              })
          }
1097c2ce1   Swarn Singh   margin module add...
18
          $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId'));
e8983332d   Swarn Singh   margin accordian ...
19

1097c2ce1   Swarn Singh   margin module add...
20
          updateFuelManagerService.getATypeJets($scope.userProfileId).then(function(result) {
1097c2ce1   Swarn Singh   margin module add...
21
22
            $scope.aTypeJets = result;
          })
1097c2ce1   Swarn Singh   margin module add...
23
24
25
26
27
28
          $scope.toggleJestAccordian = function(id){
              $('.'+id).slideDown();
              $('#'+id).addClass('customActive');
              $('#'+id+' select, #'+id+' input').prop("disabled", false);
              $('#'+id+' .btn-success, #'+id+' .btn-danger').css('display', 'inline-block');
              $('#'+id+' .btn-default').css('display', 'none');
05c2f6fb3   Swarn Singh   margin module and...
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
60
61
62
63
64
65
66
  
              updateFuelManagerService.getJetTiers(id).then(function(tiers) {
                $scope.tierList = tiers;
              })
          }
          $scope.tr = {};
          $scope.addNewTier = function(id){
              $scope.tr.marginTotal = '1.00';
              $scope.tr.marginTemplateId = id;
  
              var tierData = 'minTierBreak='+$scope.tr.minTierBreak+'&maxTierBreak='+$scope.tr.maxTierBreak+'&margin='+$scope.tr.margin+
              '&marginTotal='+$scope.tr.marginTotal+'&marginTemplateId='+$scope.tr.marginTemplateId;
  
              updateFuelManagerService.addNewTier(tierData).then(function(result) {
                  toastr.success('Successfully Added', {
                    closeButton: true
                  })
                  $scope.tr = {};
                  updateFuelManagerService.getJetTiers(id).then(function(tiers) {
                    $scope.tierList = tiers;
                  })
              })
          }
  
          $scope.editTier = function(tier){
              var editTierData = 'minTierBreak='+tier.minTierBreak+'&maxTierBreak='+tier.maxTierBreak+'&margin='+tier.margin+
              '&marginTotal='+tier.marginTotal+'&marginTemplateId='+tier.marginTemplate.id+'&marginId='+tier.id;
  
              updateFuelManagerService.editTier(editTierData).then(function(result) {
                  toastr.success('Successfully Updated', {
                    closeButton: true
                  })
                  updateFuelManagerService.getJetTiers(tier.marginTemplate.id).then(function(tiers) {
                    $scope.tierList = tiers;
                  })
              })
  
          }
90e918562   Swarn Singh   delete tier done
67
          $scope.deleteTier = function(id, jetid){
05c2f6fb3   Swarn Singh   margin module and...
68
              updateFuelManagerService.deleteTier(id).then(function(result) {
90e918562   Swarn Singh   delete tier done
69
                  toastr.success(''+result.success+'', {
05c2f6fb3   Swarn Singh   margin module and...
70
71
                    closeButton: true
                  })
90e918562   Swarn Singh   delete tier done
72
                  updateFuelManagerService.getJetTiers(jetid).then(function(tiers) {
05c2f6fb3   Swarn Singh   margin module and...
73
74
75
                    $scope.tierList = tiers;
                  })
              })
1097c2ce1   Swarn Singh   margin module add...
76
          }
e8983332d   Swarn Singh   margin accordian ...
77

1097c2ce1   Swarn Singh   margin module add...
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
          $scope.saveJetAccordian = function(jets){
              $scope.jetsDetail = jets;
              $scope.jetsDetail.userProfileId = $scope.userProfileId;
              //console.log('jets', $scope.jetsDetail);
              $('.'+$scope.jetsDetail.id).slideUp();
              $('#'+$scope.jetsDetail.id).removeClass('customActive');
              $('#'+$scope.jetsDetail.id+' select, #'+$scope.jetsDetail.id+' input').prop("disabled", true);
              $('#'+$scope.jetsDetail.id+' .btn-success, #'+$scope.jetsDetail.id+' .btn-danger').css('display', 'none');
              $('#'+$scope.jetsDetail.id+' .btn-default').css('display', 'inline-block');
  
              var editJetData = 'productType='+$scope.jetsDetail.productType+'&marginName='+$scope.jetsDetail.marginName+'&pricingStructure='+$scope.jetsDetail.pricingStructure+'&marginValue='+$scope.jetsDetail.marginValue+'&userProfileId='+$scope.jetsDetail.userProfileId+'&marginId='+$scope.jetsDetail.id;
  
              updateFuelManagerService.editAtypeJetMargin(editJetData).then(function(result) {
                  console.log('newJet', editJetData);
                  toastr.success('Successfully Updated', {
                    closeButton: true
                  })
                  updateFuelManagerService.getATypeJets($scope.userProfileId).then(function(result) {
                    console.log('result', result);
                    $scope.aTypeJets = result;
                  })
e8983332d   Swarn Singh   margin accordian ...
99
              })
e8983332d   Swarn Singh   margin accordian ...
100

1097c2ce1   Swarn Singh   margin module add...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
          }
  
          $scope.addNewMarginBtn = function(){
              $('.addNewMargin').css('display', 'block');
          }
          $scope.closeMarginPopup = function(){
              $('.addNewMargin').css('display', 'none');
          }
  
          $scope.newJet = {};
          $scope.newJet.productType = '';
  
          $scope.addNewATypeJet = function(){
              $scope.newJet.productType = 'JET-A';
              $scope.newJet.userProfileId = $scope.userProfileId;
  
              var jetData = 'productType='+$scope.newJet.productType+'&marginName='+$scope.newJet.marginName+'&pricingStructure='+$scope.newJet.pricingStructure+'&marginValue='+$scope.newJet.marginValue+'&userProfileId='+$scope.newJet.userProfileId;
  
              updateFuelManagerService.addNewAtypeJetMargin(jetData).then(function(result) {
                  console.log('newJet', jetData);
                  toastr.success('Successfully Added', {
                    closeButton: true
                  })
                  $('.addNewMargin').css('display', 'none');
                  updateFuelManagerService.getATypeJets($scope.userProfileId).then(function(result) {
                    console.log('result', result);
                    $scope.aTypeJets = result;
                  })
e8983332d   Swarn Singh   margin accordian ...
129
              })
1097c2ce1   Swarn Singh   margin module add...
130
          }
e8983332d   Swarn Singh   margin accordian ...
131

1097c2ce1   Swarn Singh   margin module add...
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
         /* $scope.addNewATypeJet = function(){
              $scope.newJet.productType = 'JET-A';
              $scope.newJet.userProfileId = $scope.userProfileId;
  
              var jetData = 'productType='+$scope.newJet.productType+'&marginName='+$scope.newJet.marginName+'&pricingStructure='+$scope.newJet.pricingStructure+'&marginValue='+$scope.newJet.marginValue+'&userProfileId='+$scope.newJet.userProfileId;
  
              updateFuelManagerService.addNewAtypeJetMargin(jetData).then(function(result) {
                  console.log('newJet', jetData);
                  toastr.success('Successfully Added', {
                    closeButton: true
                  })
                  $('.addNewMargin').css('display', 'none');
                  updateFuelManagerService.getATypeJets($scope.userProfileId).then(function(result) {
                    console.log('result', result);
                    $scope.aTypeJets = result;
                  })
e8983332d   Swarn Singh   margin accordian ...
148
              })
1097c2ce1   Swarn Singh   margin module add...
149
          }*/
e8983332d   Swarn Singh   margin accordian ...
150

feacde5ff   Rishav   setup acuefuel in...
151
152
  
      }]);