Blame view

app/partials/viewFuelVendor/viewFuelVendor.controller.js 6.89 KB
cd330b5ee   Rishav   fuel vendor and v...
1
2
3
4
5
  
  'use strict';
  
   //Load controller
    angular.module('acufuel')
ea15674c8   Rishav   minor changes for...
6
  	.controller('ViewFuelVendorController', ['$scope','$uibModal', '$stateParams', 'ViewFuelVendorService', 'CustomersService', function($scope , $uibModal, $stateParams, ViewFuelVendorService, CustomersService) {
cd330b5ee   Rishav   fuel vendor and v...
7
8
9
          $scope.data = {};
          $scope.data.priceEmail = true;
          $scope.aircraft = {};
d24318592   Rishav   changes and new i...
10
          $scope.showLoader = false;
cd330b5ee   Rishav   fuel vendor and v...
11
12
          var value = "";
          var vendorId = $stateParams.id;
ea15674c8   Rishav   minor changes for...
13
          ViewFuelVendorService.getFuelOrder(vendorId).then(function(result) {
cd330b5ee   Rishav   fuel vendor and v...
14
            $scope.vendorData = result;
cd330b5ee   Rishav   fuel vendor and v...
15
16
17
18
          })
  
          getContactList();
          function getContactList(){
ea15674c8   Rishav   minor changes for...
19
            ViewFuelVendorService.getContact(vendorId).then(function(result) {
cd330b5ee   Rishav   fuel vendor and v...
20
              $scope.vendorContactList = result;
cd330b5ee   Rishav   fuel vendor and v...
21
22
23
24
25
            })
          }
  
          getAircraftList();
          function getAircraftList(){
ea15674c8   Rishav   minor changes for...
26
            ViewFuelVendorService.getAircraft(vendorId).then(function(result) {
cd330b5ee   Rishav   fuel vendor and v...
27
28
29
30
31
32
33
34
35
36
              $scope.contactAircraftList = result;
            })
          }
          
  
          $scope.contactData = {};
          $scope.contactData.contactList = [];
          $scope.addContact = function(){
            $scope.data.vendorId = vendorId;
            $scope.contactData.contactList.push($scope.data);
ea15674c8   Rishav   minor changes for...
37
            ViewFuelVendorService.addContact($scope.contactData).then(function(result) {
cd330b5ee   Rishav   fuel vendor and v...
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
              if(result.success){
                toastr.success(''+result.success+'', {
                    closeButton: true
                  })
                  $('#contact-modal-3').modal('hide');
                  getContactList();
              }else{
                toastr.error(''+result.statusText+'', {
                    closeButton: true
                  })
              }
            })
          }
  
        getData();
        function getData(){
          CustomersService.getAircraftMake().then(function(result) {
            $scope.aircraftMakeList = result;
          })
        }
        
        $scope.aircraftDetails = [{ 
              'tail':'',
              'make': '',
              'model': '',
              'sizeId' : ''
          }];
      
          $scope.addNew = function(){
              $scope.aircraftDetails.push({ 
                'tail':'',
                'make': '',
                'model': '',
                'sizeId' : ''
              });
              console.log($scope.aircraftDetails)
          };
  
          $scope.getModal = function(makeId, index){
d24318592   Rishav   changes and new i...
77
78
            $scope.showLoader = true;
            $scope.aircraft.make = makeId;
cd330b5ee   Rishav   fuel vendor and v...
79
80
            //var makeId = makeId;
            CustomersService.getModal($scope.aircraft.make).then(function(result) {
d24318592   Rishav   changes and new i...
81
              $scope.showLoader = false;
cd330b5ee   Rishav   fuel vendor and v...
82
83
84
85
86
87
              $scope.aircraftDetails[index].aircraftModalList = result;
              //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0];
            })
          }
  
          $scope.getSize = function(model, index){
d24318592   Rishav   changes and new i...
88
            $scope.showLoader = true;
cd330b5ee   Rishav   fuel vendor and v...
89
            CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) {
d24318592   Rishav   changes and new i...
90
              $scope.showLoader = false;
cd330b5ee   Rishav   fuel vendor and v...
91
92
93
94
95
96
97
98
99
100
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
              $scope.aircraftDetails[index].aircraftSizeList = result;
              //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0];
            })
          }
  
          $scope.aircraftListData = {};
          $scope.addData = [];
          $scope.saveVendorData = function(){
            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
                });
            }
            console.log($scope.addData)
            $scope.aircraftListData.aircraftList = $scope.addData;
            $scope.aircraftListData.accountId = vendorId;
            
            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
                  })
              }
            });
            
          }
          $scope.showNoteData = true;
          $scope.showCompanyName = true;
          $scope.showAddress = true;
          $scope.showNote = function(){
            $scope.showNoteData = false;
          }
  
          $scope.company = function(){
            $scope.showCompanyName = false;
          }
  
          $scope.addressChange = function(){
            $scope.showAddress = false;
          }
  
          $scope.editData = function(inputName) {
              console.log($scope.vendorData)
              if(inputName == 'showNoteData'){
                $scope.showNoteData = true;
              }else if(inputName == 'showCompanyName'){
                $scope.showCompanyName = true;
              }else if(inputName == 'showAddress'){
                $scope.showAddress = true;              
              }
  
              var vendorData = "companyName=" + $scope.vendorData.companyName + "&masterMargin=" + $scope.vendorData.masterMargin 
                + "&addressOne=" + $scope.vendorData.addressOne + "&addressTwo=" + $scope.vendorData.addressTwo + "&city=" + $scope.vendorData.city + "&state=" 
                + $scope.vendorData.state + "&country=" + $scope.vendorData.country + "&zipcode=" + $scope.vendorData.zipcode + "&internalNote=" 
                + $scope.vendorData.internalNote + "&certificateType=" + $scope.vendorData.certificateType + "&baseTenant=" + $scope.vendorData.baseTenant
                + "&fuelerlinxCustomer=" + $scope.vendorData.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.vendorData.contractFuelVendor 
                + "&activate=" + $scope.vendorData.activate + "&baseIcao=" + $scope.vendorData.baseIcao + "&vendorId=" + vendorId;
ea15674c8   Rishav   minor changes for...
157
              ViewFuelVendorService.updateContact(vendorData).then(function(result) {
cd330b5ee   Rishav   fuel vendor and v...
158
159
160
161
162
163
164
165
166
167
168
169
170
171
                if(result != null && result.success){
                  toastr.success(''+result.success+'', {
                    closeButton: true
                  })
                }else{
                  toastr.error(''+result.statusText+'', {
                    closeButton: true
                  })
                }
              })
              
          }
  
          $scope.sendMail = function(){
ea15674c8   Rishav   minor changes for...
172
            ViewFuelVendorService.sendMail(vendorId).then(function(result) {
cd330b5ee   Rishav   fuel vendor and v...
173
174
175
176
177
178
179
180
181
182
183
                if(result != null && result.success){
                  toastr.success(''+result.success+'', {
                    closeButton: true
                  })
                }else{
                  toastr.error(''+result.statusText+'', {
                    closeButton: true
                  })
                }
            })
          }
3a9f4472b   Rishav   Implement contact...
184
185
186
187
188
189
190
191
192
  
          $scope.openConfirmMail = function(){
            $('#confirm2').css('display', 'block');
          }
  
  
          $scope.cancelAndCloseConfirm = function(){
            $('#confirm2').css('display', 'none');
          }
cd330b5ee   Rishav   fuel vendor and v...
193
    }]);