Commit cb54d5ea48a46524be3d49ff0587f7d17e62ef42
1 parent
c7e2fd1622
Exists in
master
testing1
Showing
1 changed file
with
4 additions
and
0 deletions
Show diff stats
app/partials/viewCompany/viewCompany.controller.js
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | //Load controller | 3 | //Load controller |
4 | angular.module('acufuel') | 4 | angular.module('acufuel') |
5 | 5 | ||
6 | .controller('viewCompanyController', ['$scope', '$uibModal', '$stateParams', 'ViewCompanyService', 'CustomersService', 'updateFuelManagerService', 'ViewFuelVendorService', 'ViewcontactService', '$state', 'fuelOrdersService', 'enterFuelOrderService', 'NgTableParams', function($scope, $uibModal, $stateParams, ViewCompanyService, CustomersService, updateFuelManagerService, ViewFuelVendorService, ViewcontactService, $state, fuelOrdersService, enterFuelOrderService, NgTableParams) { | 6 | .controller('viewCompanyController', ['$scope', '$uibModal', '$stateParams', 'ViewCompanyService', 'CustomersService', 'updateFuelManagerService', 'ViewFuelVendorService', 'ViewcontactService', '$state', 'fuelOrdersService', 'enterFuelOrderService', 'NgTableParams', function($scope, $uibModal, $stateParams, ViewCompanyService, CustomersService, updateFuelManagerService, ViewFuelVendorService, ViewcontactService, $state, fuelOrdersService, enterFuelOrderService, NgTableParams) { |
7 | $scope.data = {}; | 7 | $scope.data = {}; |
8 | $scope.data.priceEmail = true; | 8 | $scope.data.priceEmail = true; |
9 | $scope.aircraft = {}; | 9 | $scope.aircraft = {}; |
10 | $scope.primayData = {}; | 10 | $scope.primayData = {}; |
11 | $scope.showLoader = false; | 11 | $scope.showLoader = false; |
12 | $scope.showUpdateBtn = false; | 12 | $scope.showUpdateBtn = false; |
13 | $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')); | 13 | $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')); |
14 | $scope.selected = []; | 14 | $scope.selected = []; |
15 | $scope.jetShow = []; | 15 | $scope.jetShow = []; |
16 | $scope.marginShow = []; | 16 | $scope.marginShow = []; |
17 | $scope.compId = $stateParams.id; | 17 | $scope.compId = $stateParams.id; |
18 | $scope.jetShow[0] = true; | 18 | $scope.jetShow[0] = true; |
19 | $scope.marginShow[0] = true; | 19 | $scope.marginShow[0] = true; |
20 | $scope.dispatchOrder = {}; | 20 | $scope.dispatchOrder = {}; |
21 | $scope.dispatchOrder.fuelOrderList = []; | 21 | $scope.dispatchOrder.fuelOrderList = []; |
22 | $scope.statusFilterOptions = []; | 22 | $scope.statusFilterOptions = []; |
23 | $scope.companyList = {}; | 23 | $scope.companyList = {}; |
24 | $scope.statusFilterOptions.push({ | 24 | $scope.statusFilterOptions.push({ |
25 | 'id': '', | 25 | 'id': '', |
26 | 'title': 'Show All' | 26 | 'title': 'Show All' |
27 | }, { | 27 | }, { |
28 | 'id': 'pending', | 28 | 'id': 'pending', |
29 | 'title': 'Pending' | 29 | 'title': 'Pending' |
30 | }, { | 30 | }, { |
31 | 'id': 'invoiced', | 31 | 'id': 'invoiced', |
32 | 'title': 'Invoiced' | 32 | 'title': 'Invoiced' |
33 | }, { | 33 | }, { |
34 | 'id': 'paid', | 34 | 'id': 'paid', |
35 | 'title': 'Paid' | 35 | 'title': 'Paid' |
36 | }, { | 36 | }, { |
37 | 'id': 'cancelled', | 37 | 'id': 'cancelled', |
38 | 'title': 'Cancelled' | 38 | 'title': 'Cancelled' |
39 | }, { | 39 | }, { |
40 | 'id': 'archived', | 40 | 'id': 'archived', |
41 | 'title': 'Archived' | 41 | 'title': 'Archived' |
42 | } | 42 | } |
43 | 43 | ||
44 | ); | 44 | ); |
45 | 45 | ||
46 | $scope.order = {}; | 46 | $scope.order = {}; |
47 | $scope.order.companyName = ''; | 47 | $scope.order.companyName = ''; |
48 | $scope.order.upliftDate = ''; | 48 | $scope.order.upliftDate = ''; |
49 | /*Get AllCompany api is used from CustomersService*/ | 49 | /*Get AllCompany api is used from CustomersService*/ |
50 | getAllCompanies(); | 50 | getAllCompanies(); |
51 | 51 | ||
52 | function getAllCompanies() { | 52 | function getAllCompanies() { |
53 | CustomersService.getAllCompanies().then(function(result) { | 53 | CustomersService.getAllCompanies().then(function(result) { |
54 | //console.log('log', result[2].id); | 54 | //console.log('log', result[2].id); |
55 | $scope.companyList = result; | 55 | $scope.companyList = result; |
56 | 56 | ||
57 | for (var i = 0; i < $scope.companyList.length; i++) { | 57 | for (var i = 0; i < $scope.companyList.length; i++) { |
58 | if ($scope.companyList[i].companyContact != null) { | 58 | if ($scope.companyList[i].companyContact != null) { |
59 | if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) { | 59 | if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) { |
60 | $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber; | 60 | $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber; |
61 | } | 61 | } |
62 | } | 62 | } |
63 | if ($scope.companyList[i].primaryContact != null) { | 63 | if ($scope.companyList[i].primaryContact != null) { |
64 | if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) { | 64 | if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) { |
65 | $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName; | 65 | $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | if ($scope.companyList[i].margin != null) { | 68 | if ($scope.companyList[i].margin != null) { |
69 | if ($scope.companyList[i].margin.marginName != null) { | 69 | if ($scope.companyList[i].margin.marginName != null) { |
70 | $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; | 70 | $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | } | 73 | } |
74 | $scope.displayCompanyList = new NgTableParams({ | 74 | $scope.displayCompanyList = new NgTableParams({ |
75 | page: 1, | 75 | page: 1, |
76 | count: 10, | 76 | count: 10, |
77 | }, { | 77 | }, { |
78 | data: $scope.companyList | 78 | data: $scope.companyList |
79 | }); | 79 | }); |
80 | $scope.showLoader = false; | 80 | $scope.showLoader = false; |
81 | }) | 81 | }) |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | $(document).ready(function() { | 85 | $(document).ready(function() { |
86 | $("#reset").click(function() { | 86 | $("#reset").click(function() { |
87 | $("input").val(""); | 87 | $("input").val(""); |
88 | }); | 88 | }); |
89 | }); | 89 | }); |
90 | 90 | ||
91 | $scope.values = [{ | 91 | $scope.values = [{ |
92 | 'id': 1, | 92 | 'id': 1, |
93 | 'first': 'Tenant/Base Customer' | 93 | 'first': 'Tenant/Base Customer' |
94 | }, | 94 | }, |
95 | { | 95 | { |
96 | 'id': 2, | 96 | 'id': 2, |
97 | 'first': 'FuelerLinx Customer' | 97 | 'first': 'FuelerLinx Customer' |
98 | }, | 98 | }, |
99 | { | 99 | { |
100 | 'id': 3, | 100 | 'id': 3, |
101 | 'first': 'CAA Member' | 101 | 'first': 'CAA Member' |
102 | } | 102 | } |
103 | ]; | 103 | ]; |
104 | 104 | ||
105 | 105 | ||
106 | 106 | ||
107 | $scope.changeValue = function(selected) { | 107 | $scope.changeValue = function(selected) { |
108 | $scope.showUpdateBtn = true; | 108 | $scope.showUpdateBtn = true; |
109 | // console.log("data to be true", selected); | 109 | // console.log("data to be true", selected); |
110 | for (var i = 0; i < selected.length; i++) { | 110 | for (var i = 0; i < selected.length; i++) { |
111 | // console.log(selected[i]) | 111 | // console.log(selected[i]) |
112 | if (selected[i] == 'Tenant/Base Customer') { | 112 | if (selected[i] == 'Tenant/Base Customer') { |
113 | $scope.companyData.baseTenant = true; | 113 | $scope.companyData.baseTenant = true; |
114 | } else { | 114 | } else { |
115 | $scope.companyData.baseTenant = false; | 115 | $scope.companyData.baseTenant = false; |
116 | } | 116 | } |
117 | if (selected[i] == 'FuelerLinx Customer') { | 117 | if (selected[i] == 'FuelerLinx Customer') { |
118 | $scope.companyData.fuelerlinxCustomer = true; | 118 | $scope.companyData.fuelerlinxCustomer = true; |
119 | } else { | 119 | } else { |
120 | $scope.companyData.fuelerlinxCustomer = false; | 120 | $scope.companyData.fuelerlinxCustomer = false; |
121 | } | 121 | } |
122 | 122 | ||
123 | if (selected[i] == 'CAA Member') { | 123 | if (selected[i] == 'CAA Member') { |
124 | $scope.companyData.contractFuelVendor = true; | 124 | $scope.companyData.contractFuelVendor = true; |
125 | } else { | 125 | } else { |
126 | $scope.companyData.contractFuelVendor = false; | 126 | $scope.companyData.contractFuelVendor = false; |
127 | } | 127 | } |
128 | 128 | ||
129 | // console.log($scope.companyData) | 129 | // console.log($scope.companyData) |
130 | 130 | ||
131 | } | 131 | } |
132 | 132 | ||
133 | } | 133 | } |
134 | 134 | ||
135 | // $scope.selected =[ | 135 | // $scope.selected =[ |
136 | // {'id': 1, 'first': 'Tenant/Base Customer'}, | 136 | // {'id': 1, 'first': 'Tenant/Base Customer'}, |
137 | // {'id': 2, 'first': 'FuelerLinx Customer'}, | 137 | // {'id': 2, 'first': 'FuelerLinx Customer'}, |
138 | // {'id': 3, 'first': 'CAA Member'} | 138 | // {'id': 3, 'first': 'CAA Member'} |
139 | // ]; | 139 | // ]; |
140 | 140 | ||
141 | // CustomersService.getMargin().then(function(result) { | 141 | // CustomersService.getMargin().then(function(result) { |
142 | // $scope.marginList = result; | 142 | // $scope.marginList = result; |
143 | // }) | 143 | // }) |
144 | 144 | ||
145 | var value = ""; | 145 | var value = ""; |
146 | var companyId = $stateParams.id; | 146 | var companyId = $stateParams.id; |
147 | 147 | ||
148 | $scope.companyData = {}; | 148 | $scope.companyData = {}; |
149 | $scope.multipleMsg = false; | 149 | $scope.multipleMsg = false; |
150 | $scope.companyData.masterMargin = ""; | 150 | $scope.companyData.masterMargin = ""; |
151 | $scope.isGlobal = false; | 151 | $scope.isGlobal = false; |
152 | $scope.fboPreffered = false; | 152 | $scope.fboPreffered = false; |
153 | getCompanyDetail(); | 153 | getCompanyDetail(); |
154 | 154 | ||
155 | function getCompanyDetail() { | 155 | function getCompanyDetail() { |
156 | $scope.showLoader = true; | 156 | $scope.showLoader = true; |
157 | ViewCompanyService.getCompany(companyId).then(function(result) { | 157 | ViewCompanyService.getCompany(companyId).then(function(result) { |
158 | $scope.companyData = result; | 158 | $scope.companyData = result; |
159 | $scope.isGlobal = result.global; | 159 | $scope.isGlobal = result.global; |
160 | $scope.fboPreffered = result.fboPreferred; | 160 | $scope.fboPreffered = result.fboPreferred; |
161 | if (result.global == true) { | 161 | if (result.global == true) { |
162 | $scope.companyData.global = true; | 162 | $scope.companyData.global = true; |
163 | } | 163 | } |
164 | if (result.margin != null) { | 164 | if (result.margin != null) { |
165 | $scope.companyData.masterMargin = result.margin.id; | 165 | $scope.companyData.masterMargin = result.margin.id; |
166 | } | 166 | } |
167 | if (result.marginAVGAS != null) { | 167 | if (result.marginAVGAS != null) { |
168 | $scope.companyData.avgasMargin = result.marginAVGAS.id; | 168 | $scope.companyData.avgasMargin = result.marginAVGAS.id; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | 172 | ||
173 | if ($scope.companyData.baseTenant) { | 173 | if ($scope.companyData.baseTenant) { |
174 | 174 | ||
175 | $scope.selected.push({ | 175 | $scope.selected.push({ |
176 | 'first': 'Tenant/Base Customer' | 176 | 'first': 'Tenant/Base Customer' |
177 | }) | 177 | }) |
178 | // console.log("$scope.selected",$scope.selected) | 178 | // console.log("$scope.selected",$scope.selected) |
179 | 179 | ||
180 | } | 180 | } |
181 | 181 | ||
182 | if ($scope.companyData.fuelerlinxCustomer) { | 182 | if ($scope.companyData.fuelerlinxCustomer) { |
183 | $scope.selected.push({ | 183 | $scope.selected.push({ |
184 | 'first': 'FuelerLinx Customer' | 184 | 'first': 'FuelerLinx Customer' |
185 | }) | 185 | }) |
186 | // console.log("$scope.selected",$scope.selected) | 186 | // console.log("$scope.selected",$scope.selected) |
187 | } | 187 | } |
188 | 188 | ||
189 | if ($scope.companyData.contractFuelVendor) { | 189 | if ($scope.companyData.contractFuelVendor) { |
190 | $scope.selected.push({ | 190 | $scope.selected.push({ |
191 | 'first': 'CAA Member' | 191 | 'first': 'CAA Member' |
192 | }) | 192 | }) |
193 | // console.log("$scope.selected",$scope.selected) | 193 | // console.log("$scope.selected",$scope.selected) |
194 | } | 194 | } |
195 | 195 | ||
196 | // console.log("$scope.companyData",$scope.companyData) | 196 | // console.log("$scope.companyData",$scope.companyData) |
197 | getAircraftList(); | 197 | getAircraftList(); |
198 | $scope.order.companyName = $scope.companyData.companyName; | 198 | $scope.order.companyName = $scope.companyData.companyName; |
199 | $scope.getAircraft(result.companyName); | 199 | $scope.getAircraft(result.companyName); |
200 | $scope.showLoader = false; | 200 | $scope.showLoader = false; |
201 | }) | 201 | }) |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | $scope.changeCompanyStatus = function() { | 205 | $scope.changeCompanyStatus = function() { |
206 | $('#delete3').css('display', 'block'); | 206 | $('#delete3').css('display', 'block'); |
207 | if ($scope.companyData.activate == true) { | 207 | if ($scope.companyData.activate == true) { |
208 | $scope.statusMessage = 'Please confirm! Are you sure you want to ACTIVATE this company?' | 208 | $scope.statusMessage = 'Please confirm! Are you sure you want to ACTIVATE this company?' |
209 | } else { | 209 | } else { |
210 | $scope.statusMessage = 'Please confirm! Are you sure you want to DEACTIVATE this company?' | 210 | $scope.statusMessage = 'Please confirm! Are you sure you want to DEACTIVATE this company?' |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | $scope.companyStatus = function() { | 214 | $scope.companyStatus = function() { |
215 | $scope.showLoader = true; | 215 | $scope.showLoader = true; |
216 | var statusData = "status=" + $scope.companyData.activate; | 216 | var statusData = "status=" + $scope.companyData.activate; |
217 | ViewCompanyService.changeStatus(companyId, statusData).then(function(result) { | 217 | ViewCompanyService.changeStatus(companyId, statusData).then(function(result) { |
218 | if (result.success) { | 218 | if (result.success) { |
219 | $('#delete3').css('display', 'none'); | 219 | $('#delete3').css('display', 'none'); |
220 | toastr.success('' + result.success + '', { | 220 | toastr.success('' + result.success + '', { |
221 | closeButton: true | 221 | closeButton: true |
222 | }) | 222 | }) |
223 | getContactList(); | 223 | getContactList(); |
224 | } | 224 | } |
225 | }) | 225 | }) |
226 | $scope.showLoader = false; | 226 | $scope.showLoader = false; |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | $scope.cancelStatus = function() { | 230 | $scope.cancelStatus = function() { |
231 | $('#delete3').css('display', 'none'); | 231 | $('#delete3').css('display', 'none'); |
232 | $scope.companyData.activate = !$scope.companyData.activate; | 232 | $scope.companyData.activate = !$scope.companyData.activate; |
233 | } | 233 | } |
234 | 234 | ||
235 | getContactList(); | 235 | getContactList(); |
236 | 236 | ||
237 | function getContactList() { | 237 | function getContactList() { |
238 | ViewCompanyService.getContact(companyId).then(function(result) { | 238 | ViewCompanyService.getContact(companyId).then(function(result) { |
239 | $scope.companyContactList = result; | 239 | $scope.companyContactList = result; |
240 | }) | 240 | }) |
241 | } | 241 | } |
242 | $scope.aircraftmargins = []; | 242 | $scope.aircraftmargins = []; |
243 | 243 | ||
244 | $scope.abc = false; | 244 | $scope.abc = false; |
245 | $scope.xyz = false; | 245 | $scope.xyz = false; |
246 | function getAircraftList() { | 246 | function getAircraftList() { |
247 | ViewCompanyService.getAircraft(companyId).then(function(result) { | 247 | ViewCompanyService.getAircraft(companyId).then(function(result) { |
248 | 248 | ||
249 | $scope.contactAircraftList = result; | 249 | $scope.contactAircraftList = result; |
250 | for (var i = 0; i < $scope.contactAircraftList.length; i++) { | 250 | for (var i = 0; i < $scope.contactAircraftList.length; i++) { |
251 | if ($scope.contactAircraftList[i].aircraftsMargin != null) { | 251 | if ($scope.contactAircraftList[i].aircraftsMargin != null) { |
252 | $scope.aircraftmargins.push({ | 252 | $scope.aircraftmargins.push({ |
253 | 'id': $scope.contactAircraftList[i].aircraftsMargin.id | 253 | 'id': $scope.contactAircraftList[i].aircraftsMargin.id |
254 | }) | 254 | }) |
255 | $scope.contactAircraftList[i].fuelType = "Jet-A"; | 255 | $scope.contactAircraftList[i].fuelType = "Jet-A"; |
256 | $scope.contactAircraftList[i].marginValue = result[i].aircraftsMargin.marginValue; | 256 | $scope.contactAircraftList[i].marginValue = result[i].aircraftsMargin.marginValue; |
257 | $scope.abc = true; | 257 | $scope.abc = true; |
258 | 258 | ||
259 | }else{ | 259 | }else{ |
260 | $scope.contactAircraftList[i].fuelType = "100LL"; | 260 | $scope.contactAircraftList[i].fuelType = "100LL"; |
261 | if (result[i].aircraftsAVGASMargin != null) { | 261 | if (result[i].aircraftsAVGASMargin != null) { |
262 | $scope.contactAircraftList[i].marginValue = result[i].aircraftsAVGASMargin.marginValue; | 262 | $scope.contactAircraftList[i].marginValue = result[i].aircraftsAVGASMargin.marginValue; |
263 | $scope.xyz = true; | 263 | $scope.xyz = true; |
264 | 264 | ||
265 | } | 265 | } |
266 | } | 266 | } |
267 | 267 | ||
268 | } | 268 | } |
269 | if ($scope.aircraftmargins.length > 0) { | 269 | if ($scope.aircraftmargins.length > 0) { |
270 | for (var i = 0; i < $scope.aircraftmargins.length; i++) { | 270 | for (var i = 0; i < $scope.aircraftmargins.length; i++) { |
271 | if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) { | 271 | if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) { |
272 | $scope.multiple = true; | 272 | $scope.multiple = true; |
273 | $scope.multipleMsg = true; | 273 | $scope.multipleMsg = true; |
274 | if ($scope.multiple) { | 274 | if ($scope.multiple) { |
275 | $scope.companyData.masterMargin = "multiple"; | 275 | $scope.companyData.masterMargin = "multiple"; |
276 | } | 276 | } |
277 | } | 277 | } |
278 | } | 278 | } |
279 | } | 279 | } |
280 | }) | 280 | }) |
281 | } | 281 | } |
282 | 282 | ||
283 | 283 | ||
284 | 284 | ||
285 | $scope.contactData = {}; | 285 | $scope.contactData = {}; |
286 | $scope.contactData.contactList = []; | 286 | $scope.contactData.contactList = []; |
287 | $scope.addContact = function() { | 287 | $scope.addContact = function() { |
288 | $scope.showLoader = true; | 288 | $scope.showLoader = true; |
289 | $scope.data.companyId = companyId; | 289 | $scope.data.companyId = companyId; |
290 | $scope.contactData.contactList.push($scope.data); | 290 | $scope.contactData.contactList.push($scope.data); |
291 | ViewCompanyService.addContact($scope.contactData).then(function(result) { | 291 | ViewCompanyService.addContact($scope.contactData).then(function(result) { |
292 | //console.log("data==",$scope.contactData) | 292 | //console.log("data==",$scope.contactData) |
293 | // console.log(result) | 293 | // console.log(result) |
294 | if (result.status == 200) { | 294 | if (result.status == 200) { |
295 | 295 | ||
296 | $('#contact-modal-3').modal('hide'); | 296 | $('#contact-modal-3').modal('hide'); |
297 | $scope.primayData.id = result.data; | 297 | $scope.primayData.id = result.data; |
298 | $scope.data = {}; | 298 | $scope.data = {}; |
299 | $scope.sendPrimaryContact(); | 299 | $scope.sendPrimaryContact(); |
300 | getContactList(); | 300 | getContactList(); |
301 | $scope.contactData.contactList = []; | 301 | $scope.contactData.contactList = []; |
302 | $scope.data.email = ''; | 302 | $scope.data.email = ''; |
303 | toastr.success('Created Successfully', { | 303 | toastr.success('Created Successfully', { |
304 | closeButton: true | 304 | closeButton: true |
305 | }) | 305 | }) |
306 | } else { | 306 | } else { |
307 | toastr.error('' + result.statusText + '', { | 307 | toastr.error('' + result.statusText + '', { |
308 | closeButton: true | 308 | closeButton: true |
309 | }) | 309 | }) |
310 | } | 310 | } |
311 | }) | 311 | }) |
312 | $scope.showLoader = false; | 312 | $scope.showLoader = false; |
313 | } | 313 | } |
314 | 314 | ||
315 | getData(); | 315 | getData(); |
316 | 316 | ||
317 | function getData() { | 317 | function getData() { |
318 | $scope.showLoader = true; | 318 | $scope.showLoader = true; |
319 | CustomersService.getAircraftMake().then(function(result) { | 319 | CustomersService.getAircraftMake().then(function(result) { |
320 | $scope.aircraftMakeList = result; | 320 | $scope.aircraftMakeList = result; |
321 | // console.log("make",result) | 321 | // console.log("make",result) |
322 | }) | 322 | }) |
323 | $scope.showLoader = false; | 323 | $scope.showLoader = false; |
324 | } | 324 | } |
325 | 325 | ||
326 | $scope.clearAircrafts = function() { | 326 | $scope.clearAircrafts = function() { |
327 | $scope.aircraftDetails = []; | 327 | $scope.aircraftDetails = []; |
328 | $scope.aircraftDetails = [{ | 328 | $scope.aircraftDetails = [{ |
329 | 'tail': '', | 329 | 'tail': '', |
330 | 'make': '', | 330 | 'make': '', |
331 | 'model': '', | 331 | 'model': '', |
332 | 'sizeId': '', | 332 | 'sizeId': '', |
333 | 'marginId': '', | 333 | 'marginId': '', |
334 | 'avgasMarginId': '' | 334 | 'avgasMarginId': '' |
335 | }]; | 335 | }]; |
336 | } | 336 | } |
337 | 337 | ||
338 | $scope.addNew = function() { | 338 | $scope.addNew = function() { |
339 | $scope.aircraftDetails.push({ | 339 | $scope.aircraftDetails.push({ |
340 | 'tail': '', | 340 | 'tail': '', |
341 | 'make': '', | 341 | 'make': '', |
342 | 'model': '', | 342 | 'model': '', |
343 | 'sizeId': '', | 343 | 'sizeId': '', |
344 | 'marginId': '', | 344 | 'marginId': '', |
345 | 'avgasMarginId': '' | 345 | 'avgasMarginId': '' |
346 | }); | 346 | }); |
347 | // console.log($scope.aircraftDetails) | 347 | // console.log($scope.aircraftDetails) |
348 | }; | 348 | }; |
349 | 349 | ||
350 | $scope.getModal = function(makeId, index) { | 350 | $scope.getModal = function(makeId, index) { |
351 | $scope.showLoader = true; | 351 | $scope.showLoader = true; |
352 | $scope.aircraft.make = makeId; | 352 | $scope.aircraft.make = makeId; |
353 | CustomersService.getModal($scope.aircraft.make).then(function(result) { | 353 | CustomersService.getModal($scope.aircraft.make).then(function(result) { |
354 | $scope.showLoader = false; | 354 | $scope.showLoader = false; |
355 | $scope.aircraftDetails[index].aircraftModalList = result; | 355 | $scope.aircraftDetails[index].aircraftModalList = result; |
356 | //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; | 356 | //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; |
357 | }) | 357 | }) |
358 | } | 358 | } |
359 | 359 | ||
360 | $scope.selectedOption = ''; | 360 | $scope.selectedOption = ''; |
361 | $scope.getSize = function(model, index) { | 361 | $scope.getSize = function(model, index) { |
362 | $scope.showLoader = true; | 362 | $scope.showLoader = true; |
363 | $scope.aircraft.model = model; | 363 | $scope.aircraft.model = model; |
364 | CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { | 364 | CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { |
365 | $scope.showLoader = false; | 365 | $scope.showLoader = false; |
366 | $scope.aircraftDetails[index].aircraftSizeList = result; | 366 | $scope.aircraftDetails[index].aircraftSizeList = result; |
367 | $scope.getFuelType($scope.aircraftDetails[index].aircraftSizeList[0].aircraftSize.id,index); | 367 | $scope.getFuelType($scope.aircraftDetails[index].aircraftSizeList[0].aircraftSize.id,index); |
368 | 368 | ||
369 | 369 | ||
370 | }) | 370 | }) |
371 | } | 371 | } |
372 | 372 | ||
373 | $scope.getFuelType = function(size, index) { | 373 | $scope.getFuelType = function(size, index) { |
374 | $scope.showLoader = true; | 374 | $scope.showLoader = true; |
375 | var data = "model="+$scope.aircraft.model+"&make="+$scope.aircraft.make+"&sizeId="+size; | 375 | var data = "model="+$scope.aircraft.model+"&make="+$scope.aircraft.make+"&sizeId="+size; |
376 | ViewCompanyService.checkFuelType(data).then(function(result){ | 376 | ViewCompanyService.checkFuelType(data).then(function(result){ |
377 | $scope.showLoader = false; | 377 | $scope.showLoader = false; |
378 | if (result.type == "JetA") { | 378 | if (result.type == "JetA") { |
379 | $scope.jetShow[index] = false; | 379 | $scope.jetShow[index] = false; |
380 | $scope.marginShow[index] = true; | 380 | $scope.marginShow[index] = true; |
381 | } else if (result.type == "Avgas") { | 381 | } else if (result.type == "Avgas") { |
382 | $scope.jetShow[index] = true; | 382 | $scope.jetShow[index] = true; |
383 | $scope.marginShow[index] = false; | 383 | $scope.marginShow[index] = false; |
384 | }else { | 384 | }else { |
385 | $scope.jetShow[index] = true; | 385 | $scope.jetShow[index] = true; |
386 | $scope.marginShow[index] = true; | 386 | $scope.marginShow[index] = true; |
387 | } | 387 | } |
388 | }) | 388 | }) |
389 | } | 389 | } |
390 | 390 | ||
391 | $scope.aircraftListData = {}; | 391 | $scope.aircraftListData = {}; |
392 | $scope.addData = []; | 392 | $scope.addData = []; |
393 | $scope.tailArray = []; | 393 | $scope.tailArray = []; |
394 | function check(array){ | 394 | function check(array){ |
395 | return (new Set(array)).size !== array.length; | 395 | return (new Set(array)).size !== array.length; |
396 | } | 396 | } |
397 | $scope.saveCompanyData = function() { | 397 | $scope.saveCompanyData = function() { |
398 | $scope.tailArray = []; | 398 | $scope.tailArray = []; |
399 | for (var i = 0; i < $scope.aircraftDetails.length; i++) { | 399 | for (var i = 0; i < $scope.aircraftDetails.length; i++) { |
400 | $scope.addData.push({ | 400 | $scope.addData.push({ |
401 | 'tail': $scope.aircraftDetails[i].tail, | 401 | 'tail': $scope.aircraftDetails[i].tail, |
402 | 'make': $scope.aircraftDetails[i].make, | 402 | 'make': $scope.aircraftDetails[i].make, |
403 | 'model': $scope.aircraftDetails[i].model, | 403 | 'model': $scope.aircraftDetails[i].model, |
404 | 'sizeId': $scope.aircraftDetails[i].sizeId, | 404 | 'sizeId': $scope.aircraftDetails[i].sizeId, |
405 | 'marginId': $scope.aircraftDetails[i].marginId, | 405 | 'marginId': $scope.aircraftDetails[i].marginId, |
406 | 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId | 406 | 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId |
407 | }); | 407 | }); |
408 | $scope.tailArray.push($scope.aircraftDetails[i].tail); | 408 | $scope.tailArray.push($scope.aircraftDetails[i].tail); |
409 | } | 409 | } |
410 | if (check($scope.tailArray)) { | 410 | if (check($scope.tailArray)) { |
411 | toastr.error('Duplicate Tail Added.', { | 411 | toastr.error('Duplicate Tail Added.', { |
412 | closeButton: true | 412 | closeButton: true |
413 | }) | 413 | }) |
414 | }else{ | 414 | }else{ |
415 | $scope.aircraftListData.aircraftList = $scope.addData; | 415 | $scope.aircraftListData.aircraftList = $scope.addData; |
416 | $scope.aircraftListData.accountId = companyId; | 416 | $scope.aircraftListData.accountId = companyId; |
417 | CustomersService.addAircraft($scope.aircraftListData).then(function(result) { | 417 | CustomersService.addAircraft($scope.aircraftListData).then(function(result) { |
418 | if (result != null && result.success) { | 418 | if (result != null && result.success) { |
419 | toastr.success('' + result.success + '', { | 419 | toastr.success('' + result.success + '', { |
420 | closeButton: true | 420 | closeButton: true |
421 | }) | 421 | }) |
422 | $scope.addData= []; | 422 | $scope.addData= []; |
423 | $scope.tailArray = []; | 423 | $scope.tailArray = []; |
424 | $scope.aircraftListData={}; | 424 | $scope.aircraftListData={}; |
425 | $('#aircraft-modal-3').css('display', 'none'); | 425 | $('#aircraft-modal-3').css('display', 'none'); |
426 | $('.modal-backdrop').css('display', 'none'); | 426 | $('.modal-backdrop').css('display', 'none'); |
427 | $('#aircraft-modal-3').modal('hide'); | 427 | $('#aircraft-modal-3').modal('hide'); |
428 | $('.modal-backdrop').modal('hide'); | 428 | $('.modal-backdrop').modal('hide'); |
429 | getAircraftList(); | 429 | getAircraftList(); |
430 | 430 | ||
431 | } else { | 431 | } else { |
432 | $('#aircraft-modal-3').css('display', 'none'); | 432 | $('#aircraft-modal-3').css('display', 'none'); |
433 | $('.modal-backdrop').css('display', 'none'); | 433 | $('.modal-backdrop').css('display', 'none'); |
434 | toastr.error('' + result.statusText + '', { | 434 | toastr.error('' + result.statusText + '', { |
435 | closeButton: true | 435 | closeButton: true |
436 | }) | 436 | }) |
437 | } | 437 | } |
438 | }); | 438 | }); |
439 | } | 439 | } |
440 | 440 | ||
441 | } | 441 | } |
442 | 442 | ||
443 | $scope.showNoteData = true; | 443 | $scope.showNoteData = true; |
444 | $scope.showCompanyName = true; | 444 | $scope.showCompanyName = true; |
445 | $scope.showAddress = true; | 445 | $scope.showAddress = true; |
446 | $scope.showNote = function() { | 446 | $scope.showNote = function() { |
447 | $scope.showNoteData = false; | 447 | $scope.showNoteData = false; |
448 | $scope.showUpdateBtn = true; | 448 | $scope.showUpdateBtn = true; |
449 | } | 449 | } |
450 | 450 | ||
451 | $scope.company = function() { | 451 | $scope.company = function() { |
452 | $scope.showCompanyName = false; | 452 | $scope.showCompanyName = false; |
453 | $scope.showUpdateBtn = true; | 453 | $scope.showUpdateBtn = true; |
454 | } | 454 | } |
455 | 455 | ||
456 | $scope.base = function() { | 456 | $scope.base = function() { |
457 | $scope.showUpdateBtn = true; | 457 | $scope.showUpdateBtn = true; |
458 | } | 458 | } |
459 | 459 | ||
460 | $scope.addressChange = function() { | 460 | $scope.addressChange = function() { |
461 | $scope.showAddress = false; | 461 | $scope.showAddress = false; |
462 | $scope.showUpdateBtn = true; | 462 | $scope.showUpdateBtn = true; |
463 | } | 463 | } |
464 | 464 | ||
465 | $scope.editData = function(inputName) { | 465 | $scope.editData = function(inputName) { |
466 | //console.log($scope.companyData) | 466 | //console.log($scope.companyData) |
467 | $scope.showLoader = true; | 467 | $scope.showLoader = true; |
468 | /*if(inputName == 'showNoteData'){ | 468 | /*if(inputName == 'showNoteData'){ |
469 | $scope.showNoteData = true; | 469 | $scope.showNoteData = true; |
470 | }else if(inputName == 'showCompanyName'){ | 470 | }else if(inputName == 'showCompanyName'){ |
471 | $scope.showCompanyName = true; | 471 | $scope.showCompanyName = true; |
472 | }else if(inputName == 'showAddress'){ | 472 | }else if(inputName == 'showAddress'){ |
473 | $scope.showAddress = true; | 473 | $scope.showAddress = true; |
474 | }*/ | 474 | }*/ |
475 | $scope.showNoteData = true; | 475 | $scope.showNoteData = true; |
476 | $scope.showCompanyName = true; | 476 | $scope.showCompanyName = true; |
477 | $scope.showAddress = true; | 477 | $scope.showAddress = true; |
478 | 478 | ||
479 | var companyData = "companyName=" + $scope.companyData.companyName + "&masterMargin=" + $scope.companyData.masterMargin + "&avgasMargin=" + $scope.companyData.avgasMargin + | 479 | var companyData = "companyName=" + $scope.companyData.companyName + "&masterMargin=" + $scope.companyData.masterMargin + "&avgasMargin=" + $scope.companyData.avgasMargin + |
480 | "&addressOne=" + $scope.companyData.addressOne + "&addressTwo=" + $scope.companyData.addressTwo + "&city=" + $scope.companyData.city + "&state=" + | 480 | "&addressOne=" + $scope.companyData.addressOne + "&addressTwo=" + $scope.companyData.addressTwo + "&city=" + $scope.companyData.city + "&state=" + |
481 | $scope.companyData.state + "&country=" + $scope.companyData.country + "&zipcode=" + $scope.companyData.zipcode + "&internalNote=" + | 481 | $scope.companyData.state + "&country=" + $scope.companyData.country + "&zipcode=" + $scope.companyData.zipcode + "&internalNote=" + |
482 | $scope.companyData.internalNote + "&certificateType=" + $scope.companyData.certificateType + "&baseTenant=" + $scope.companyData.baseTenant + | 482 | $scope.companyData.internalNote + "&certificateType=" + $scope.companyData.certificateType + "&baseTenant=" + $scope.companyData.baseTenant + |
483 | "&fuelerlinxCustomer=" + $scope.companyData.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.companyData.contractFuelVendor + | 483 | "&fuelerlinxCustomer=" + $scope.companyData.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.companyData.contractFuelVendor + |
484 | "&activate=" + $scope.companyData.activate + "&baseIcao=" + $scope.companyData.baseIcao + "&companyId=" + companyId + "&global=" + $scope.companyData.global; | 484 | "&activate=" + $scope.companyData.activate + "&baseIcao=" + $scope.companyData.baseIcao + "&companyId=" + companyId + "&global=" + $scope.companyData.global; |
485 | 485 | ||
486 | ViewCompanyService.updateCompany(companyData).then(function(result) { | 486 | ViewCompanyService.updateCompany(companyData).then(function(result) { |
487 | if (result != null && result.success) { | 487 | if (result != null && result.success) { |
488 | toastr.success('' + result.success + '', { | 488 | toastr.success('' + result.success + '', { |
489 | closeButton: true | 489 | closeButton: true |
490 | }) | 490 | }) |
491 | $scope.showUpdateBtn = false; | 491 | $scope.showUpdateBtn = false; |
492 | getCompanyDetail(); | 492 | getCompanyDetail(); |
493 | } else { | 493 | } else { |
494 | toastr.error('Error Updating Company', { | 494 | toastr.error('Error Updating Company', { |
495 | closeButton: true | 495 | closeButton: true |
496 | }) | 496 | }) |
497 | $scope.showUpdateBtn = true; | 497 | $scope.showUpdateBtn = true; |
498 | } | 498 | } |
499 | $scope.showLoader = false; | 499 | $scope.showLoader = false; |
500 | }) | 500 | }) |
501 | } | 501 | } |
502 | 502 | ||
503 | $scope.cancelUpdateData = function() { | 503 | $scope.cancelUpdateData = function() { |
504 | $scope.showNoteData = true; | 504 | $scope.showNoteData = true; |
505 | $scope.showCompanyName = true; | 505 | $scope.showCompanyName = true; |
506 | $scope.showAddress = true; | 506 | $scope.showAddress = true; |
507 | $scope.showUpdateBtn = false; | 507 | $scope.showUpdateBtn = false; |
508 | } | 508 | } |
509 | 509 | ||
510 | $scope.sendMail = function() { | 510 | $scope.sendMail = function() { |
511 | $scope.showLoader = true; | 511 | $scope.showLoader = true; |
512 | $('#confirm1').css('display', 'none'); | 512 | $('#confirm1').css('display', 'none'); |
513 | ViewCompanyService.sendMail(companyId).then(function(result) { | 513 | ViewCompanyService.sendMail(companyId).then(function(result) { |
514 | if (result != null && result.success) { | 514 | if (result != null && result.success) { |
515 | toastr.success('' + result.success + '', { | 515 | toastr.success('' + result.success + '', { |
516 | closeButton: true | 516 | closeButton: true |
517 | }) | 517 | }) |
518 | } else { | 518 | } else { |
519 | toastr.error('Error Sending Email', { | 519 | toastr.error('Error Sending Email', { |
520 | closeButton: true | 520 | closeButton: true |
521 | }) | 521 | }) |
522 | } | 522 | } |
523 | $scope.showLoader = false; | 523 | $scope.showLoader = false; |
524 | }) | 524 | }) |
525 | } | 525 | } |
526 | 526 | ||
527 | $scope.openConfirmMail = function() { | 527 | $scope.openConfirmMail = function() { |
528 | $('#confirm1').css('display', 'block'); | 528 | $('#confirm1').css('display', 'block'); |
529 | } | 529 | } |
530 | 530 | ||
531 | 531 | ||
532 | $scope.cancelAndCloseConfirm = function() { | 532 | $scope.cancelAndCloseConfirm = function() { |
533 | $('#confirm1').css('display', 'none'); | 533 | $('#confirm1').css('display', 'none'); |
534 | } | 534 | } |
535 | 535 | ||
536 | $scope.primaryContact = false; | 536 | $scope.primaryContact = false; |
537 | $scope.cancelPrimaryContact = function() { | 537 | $scope.cancelPrimaryContact = function() { |
538 | $('#primaryContact').css('display', 'none'); | 538 | $('#primaryContact').css('display', 'none'); |
539 | $scope.primaryContact = false; | 539 | $scope.primaryContact = false; |
540 | } | 540 | } |
541 | 541 | ||
542 | $scope.checkPrimaryContact = function() { | 542 | $scope.checkPrimaryContact = function() { |
543 | if ($scope.primaryContact == true) { | 543 | if ($scope.primaryContact == true) { |
544 | $scope.primaryContact = true; | 544 | $scope.primaryContact = true; |
545 | ViewCompanyService.checkPrimaryContact(companyId).then(function(result) { | 545 | ViewCompanyService.checkPrimaryContact(companyId).then(function(result) { |
546 | //console.log(result) | 546 | //console.log(result) |
547 | if (result.status == 422) { | 547 | if (result.status == 422) { |
548 | $('#primaryContact').css('display', 'block'); | 548 | $('#primaryContact').css('display', 'block'); |
549 | } | 549 | } |
550 | }) | 550 | }) |
551 | } | 551 | } |
552 | } | 552 | } |
553 | 553 | ||
554 | $scope.sendPrimaryContact = function() { | 554 | $scope.sendPrimaryContact = function() { |
555 | $('#primaryContact').css('display', 'none'); | 555 | $('#primaryContact').css('display', 'none'); |
556 | if ($scope.primayData.id != null || $scope.primayData.id != undefined) { | 556 | if ($scope.primayData.id != null || $scope.primayData.id != undefined) { |
557 | var priamryContactData = "companyContactId=" + $scope.primayData.id + "&primary=" + $scope.primaryContact; | 557 | var priamryContactData = "companyContactId=" + $scope.primayData.id + "&primary=" + $scope.primaryContact; |
558 | 558 | ||
559 | ViewCompanyService.addPrimaryContact(priamryContactData).then(function(result) { | 559 | ViewCompanyService.addPrimaryContact(priamryContactData).then(function(result) { |
560 | // console.log(result) | 560 | // console.log(result) |
561 | }) | 561 | }) |
562 | } | 562 | } |
563 | 563 | ||
564 | } | 564 | } |
565 | 565 | ||
566 | $scope.updateData = "" | 566 | $scope.updateData = "" |
567 | $scope.showUpdateContact = function(data, value) { | 567 | $scope.showUpdateContact = function(data, value) { |
568 | $('#updateContact').css('display', 'block'); | 568 | $('#updateContact').css('display', 'block'); |
569 | $scope.updateData = data; | 569 | $scope.updateData = data; |
570 | // console.log($scope.updateData) | 570 | // console.log($scope.updateData) |
571 | if ($scope.updateData.email == null) { | 571 | if ($scope.updateData.email == null) { |
572 | $scope.updateData.content = data.contactNumber; | 572 | $scope.updateData.content = data.contactNumber; |
573 | } else { | 573 | } else { |
574 | $scope.updateData.content = data.email; | 574 | $scope.updateData.content = data.email; |
575 | } | 575 | } |
576 | } | 576 | } |
577 | 577 | ||
578 | $scope.showUpdateEmail = function(data, value) { | 578 | $scope.showUpdateEmail = function(data, value) { |
579 | $('#updateEmail').css('display', 'block'); | 579 | $('#updateEmail').css('display', 'block'); |
580 | $scope.updateData = data; | 580 | $scope.updateData = data; |
581 | // console.log($scope.updateData) | 581 | // console.log($scope.updateData) |
582 | if ($scope.updateData.email == null) { | 582 | if ($scope.updateData.email == null) { |
583 | $scope.updateData.content = data.contactNumber; | 583 | $scope.updateData.content = data.contactNumber; |
584 | } else { | 584 | } else { |
585 | $scope.updateData.content = data.email; | 585 | $scope.updateData.content = data.email; |
586 | } | 586 | } |
587 | } | 587 | } |
588 | 588 | ||
589 | $scope.acceptUpdateField = function(newContactName) { | 589 | $scope.acceptUpdateField = function(newContactName) { |
590 | // console.log($scope.updateData) | 590 | // console.log($scope.updateData) |
591 | if ($scope.updateData.content == undefined) { | 591 | if ($scope.updateData.content == undefined) { |
592 | toastr.error('Please add some content', { | 592 | toastr.error('Please add some content', { |
593 | closeButton: true | 593 | closeButton: true |
594 | }) | 594 | }) |
595 | } else { | 595 | } else { |
596 | if (newContactName == 'phone') { | 596 | if (newContactName == 'phone') { |
597 | var updateCustomData = "companyId=" + companyId + "&contactNumber=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + | 597 | var updateCustomData = "companyId=" + companyId + "&contactNumber=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + |
598 | "&title=" + $scope.updateData.title; | 598 | "&title=" + $scope.updateData.title; |
599 | } else { | 599 | } else { |
600 | var updateCustomData = "companyId=" + companyId + "&email=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + | 600 | var updateCustomData = "companyId=" + companyId + "&email=" + $scope.updateData.content + "&contactId=" + $scope.updateData.id + |
601 | "&title=" + $scope.updateData.title; | 601 | "&title=" + $scope.updateData.title; |
602 | } | 602 | } |
603 | ViewCompanyService.updateCustomField(updateCustomData).then(function(result) { | 603 | ViewCompanyService.updateCustomField(updateCustomData).then(function(result) { |
604 | if (result != null && result.success) { | 604 | if (result != null && result.success) { |
605 | $('#updateContact').css('display', 'none'); | 605 | $('#updateContact').css('display', 'none'); |
606 | $('#updateEmail').css('display', 'none'); | 606 | $('#updateEmail').css('display', 'none'); |
607 | getCompanyDetail(); | 607 | getCompanyDetail(); |
608 | } | 608 | } |
609 | }) | 609 | }) |
610 | } | 610 | } |
611 | } | 611 | } |
612 | 612 | ||
613 | $scope.deleteContent = function(data){ | 613 | $scope.deleteContent = function(data){ |
614 | ViewCompanyService.deleteCustomContact(data.id).then(function(result) { | 614 | ViewCompanyService.deleteCustomContact(data.id).then(function(result) { |
615 | if (result != null && result.success) { | 615 | if (result != null && result.success) { |
616 | toastr.success('' + result.success + '', { | 616 | toastr.success('' + result.success + '', { |
617 | closeButton: true | 617 | closeButton: true |
618 | }) | 618 | }) |
619 | getCompanyDetail(); | 619 | getCompanyDetail(); |
620 | } | 620 | } |
621 | }) | 621 | }) |
622 | } | 622 | } |
623 | 623 | ||
624 | $scope.cancelUpdateField = function() { | 624 | $scope.cancelUpdateField = function() { |
625 | $('#updateContact').css('display', 'none'); | 625 | $('#updateContact').css('display', 'none'); |
626 | $('#updateEmail').css('display', 'none'); | 626 | $('#updateEmail').css('display', 'none'); |
627 | } | 627 | } |
628 | 628 | ||
629 | $scope.showEditTier2 = function(number) { | 629 | $scope.showEditTier2 = function(number) { |
630 | // console.log(number) | 630 | // console.log(number) |
631 | $scope.contactNumber = number; | 631 | $scope.contactNumber = number; |
632 | } | 632 | } |
633 | 633 | ||
634 | 634 | ||
635 | 635 | ||
636 | $scope.addCustomPhone = function(value) { | 636 | $scope.addCustomPhone = function(value) { |
637 | //console.log(value) | 637 | //console.log(value) |
638 | if (value != null) { | 638 | if (value != null) { |
639 | $('#customFieldPhone').css('display', 'block'); | 639 | $('#customFieldPhone').css('display', 'block'); |
640 | } | 640 | } |
641 | $scope.custom = {}; | 641 | $scope.custom = {}; |
642 | } | 642 | } |
643 | 643 | ||
644 | $scope.addCustomEmail = function(value) { | 644 | $scope.addCustomEmail = function(value) { |
645 | //console.log(value) | 645 | //console.log(value) |
646 | if (value != null) { | 646 | if (value != null) { |
647 | $('#customFieldEmail').css('display', 'block'); | 647 | $('#customFieldEmail').css('display', 'block'); |
648 | } | 648 | } |
649 | $scope.custom = {}; | 649 | $scope.custom = {}; |
650 | } | 650 | } |
651 | 651 | ||
652 | $scope.cancelCustomField = function() { | 652 | $scope.cancelCustomField = function() { |
653 | $('#customFieldEmail').css('display', 'none'); | 653 | $('#customFieldEmail').css('display', 'none'); |
654 | $('#customFieldPhone').css('display', 'none'); | 654 | $('#customFieldPhone').css('display', 'none'); |
655 | } | 655 | } |
656 | 656 | ||
657 | $scope.acceptCustomField = function(contactName) { | 657 | $scope.acceptCustomField = function(contactName) { |
658 | if ($scope.custom.content == undefined) { | 658 | if ($scope.custom.content == undefined) { |
659 | toastr.error('Please add some content', { | 659 | toastr.error('Please add some content', { |
660 | closeButton: true | 660 | closeButton: true |
661 | }) | 661 | }) |
662 | } else { | 662 | } else { |
663 | if (contactName == 'phone') { | 663 | if (contactName == 'phone') { |
664 | var customData = "companyId=" + companyId + "&contactNumber=" + $scope.custom.content + | 664 | var customData = "companyId=" + companyId + "&contactNumber=" + $scope.custom.content + |
665 | "&title=" + $scope.custom.title; | 665 | "&title=" + $scope.custom.title; |
666 | } else { | 666 | } else { |
667 | var customData = "companyId=" + companyId + "&email=" + $scope.custom.content + | 667 | var customData = "companyId=" + companyId + "&email=" + $scope.custom.content + |
668 | "&title=" + $scope.custom.title; | 668 | "&title=" + $scope.custom.title; |
669 | } | 669 | } |
670 | // console.log(customData.email) | 670 | // console.log(customData.email) |
671 | ViewCompanyService.addCustomField(customData).then(function(result) { | 671 | ViewCompanyService.addCustomField(customData).then(function(result) { |
672 | // console.log(result) | 672 | // console.log(result) |
673 | if (result != null && result.success) { | 673 | if (result != null && result.success) { |
674 | $('#customFieldEmail').css('display', 'none'); | 674 | $('#customFieldEmail').css('display', 'none'); |
675 | $('#customFieldPhone').css('display', 'none'); | 675 | $('#customFieldPhone').css('display', 'none'); |
676 | $scope.custom = {}; | 676 | $scope.custom = {}; |
677 | getCompanyDetail(); | 677 | getCompanyDetail(); |
678 | } | 678 | } |
679 | }) | 679 | }) |
680 | } | 680 | } |
681 | } | 681 | } |
682 | 682 | ||
683 | /* omit strike out*/ | 683 | /* omit strike out*/ |
684 | updateFuelManagerService.getFuelPricingNew().then(function(result) { | 684 | updateFuelManagerService.getFuelPricingNew().then(function(result) { |
685 | $scope.fuelPricing = result; | 685 | $scope.fuelPricing = result; |
686 | console.log("==fuel pricing==",result) | 686 | console.log("==fuel pricing==",result) |
687 | $scope.omitData; | 687 | $scope.omitData; |
688 | ViewCompanyService.getOmitCompany($scope.compId).then(function(result){ | 688 | ViewCompanyService.getOmitCompany($scope.compId).then(function(result){ |
689 | $scope.omitData = result; | 689 | $scope.omitData = result; |
690 | console.log("omit data===", $scope.omitData); | 690 | console.log("omit data===", $scope.omitData); |
691 | for(var i = 0 ; i< $scope.fuelPricing.length; i++){ | 691 | for(var i = 0 ; i< $scope.fuelPricing.length; i++){ |
692 | for(var j = 0; j<$scope.omitData.length; j++){ | 692 | for(var j = 0; j<$scope.omitData.length; j++){ |
693 | if($scope.omitData[j].marginId == $scope.fuelPricing[i].fuelPricing.id){ | 693 | if($scope.omitData[j].marginId == $scope.fuelPricing[i].fuelPricing.id){ |
694 | $scope.fuelPricing[i].fuelPricing.omit = $scope.omitData[j].omit; | 694 | $scope.fuelPricing[i].fuelPricing.omit = $scope.omitData[j].omit; |
695 | console.log("fuel.pricing.omit",$scope.fuelPricing[i].fuelPricing.omit) | 695 | console.log("fuel.pricing.omit",$scope.fuelPricing[i].fuelPricing.omit) |
696 | } | 696 | } |
697 | else { | ||
698 | console.log("hiii false") | ||
699 | $scope.fuelPricing[i].fuelPricing.omit = false; | ||
697 | } | 700 | } |
701 | } | ||
698 | } | 702 | } |
699 | 703 | ||
700 | }) | 704 | }) |
701 | 705 | ||
702 | // console.log("$scope.fuelPricing",$scope.fuelPricing) | 706 | // console.log("$scope.fuelPricing",$scope.fuelPricing) |
703 | for (var i = 0; i < $scope.fuelPricing.length; i++) { | 707 | for (var i = 0; i < $scope.fuelPricing.length; i++) { |
704 | // console.log('$scope.fuelPricing[i].fuelPricing', $scope.fuelPricing[i].fuelPricing); | 708 | // console.log('$scope.fuelPricing[i].fuelPricing', $scope.fuelPricing[i].fuelPricing); |
705 | //console.log("fuelid",$scope.fuelPricing[i].fuelPricing.id,"getid",$scope.omitData[j].id) | 709 | //console.log("fuelid",$scope.fuelPricing[i].fuelPricing.id,"getid",$scope.omitData[j].id) |
706 | if ($scope.fuelPricing[i].fuelPricing.expirationDate != null) { | 710 | if ($scope.fuelPricing[i].fuelPricing.expirationDate != null) { |
707 | $scope.fuelPricing[i].fuelPricing.expirationDate = new Date($scope.fuelPricing[i].fuelPricing.expirationDate); | 711 | $scope.fuelPricing[i].fuelPricing.expirationDate = new Date($scope.fuelPricing[i].fuelPricing.expirationDate); |
708 | var newTime = new Date($scope.fuelPricing[i].fuelPricing.expirationDate); | 712 | var newTime = new Date($scope.fuelPricing[i].fuelPricing.expirationDate); |
709 | var dmonth = newTime.getUTCMonth() + 1; //months from 1-12 | 713 | var dmonth = newTime.getUTCMonth() + 1; //months from 1-12 |
710 | var dday = newTime.getUTCDate(); | 714 | var dday = newTime.getUTCDate(); |
711 | var dyear = newTime.getUTCFullYear(); | 715 | var dyear = newTime.getUTCFullYear(); |
712 | $scope.fuelPricing[i].fuelPricing.expirationDate = dmonth + '/' + dday + '/' + dyear; | 716 | $scope.fuelPricing[i].fuelPricing.expirationDate = dmonth + '/' + dday + '/' + dyear; |
713 | } | 717 | } |
714 | // for (var j = 0; j<$scope.omitData.length; j++) { | 718 | // for (var j = 0; j<$scope.omitData.length; j++) { |
715 | // if($scope.fuelPricing[i].fuelPricing.id === $scope.omitData[j].id){ | 719 | // if($scope.fuelPricing[i].fuelPricing.id === $scope.omitData[j].id){ |
716 | 720 | ||
717 | // } | 721 | // } |
718 | // } | 722 | // } |
719 | } | 723 | } |
720 | }) | 724 | }) |
721 | 725 | ||
722 | var deleteAircraftId = ""; | 726 | var deleteAircraftId = ""; |
723 | $scope.deleteAircraft = function(id) { | 727 | $scope.deleteAircraft = function(id) { |
724 | $('#delete1').css('display', 'block'); | 728 | $('#delete1').css('display', 'block'); |
725 | deleteAircraftId = id; | 729 | deleteAircraftId = id; |
726 | } | 730 | } |
727 | 731 | ||
728 | $scope.aircraftDelete = function() { | 732 | $scope.aircraftDelete = function() { |
729 | ViewCompanyService.deleteAircraft(deleteAircraftId).then(function(result) { | 733 | ViewCompanyService.deleteAircraft(deleteAircraftId).then(function(result) { |
730 | // console.log(result) | 734 | // console.log(result) |
731 | getAircraftList(); | 735 | getAircraftList(); |
732 | getCompanyDetail(); | 736 | getCompanyDetail(); |
733 | $('#delete1').css('display', 'none'); | 737 | $('#delete1').css('display', 'none'); |
734 | }) | 738 | }) |
735 | } | 739 | } |
736 | 740 | ||
737 | $scope.cancelAircraft = function() { | 741 | $scope.cancelAircraft = function() { |
738 | $('#delete1').css('display', 'none'); | 742 | $('#delete1').css('display', 'none'); |
739 | } | 743 | } |
740 | 744 | ||
741 | CustomersService.getJetMargin($scope.userProfileId).then(function(result) { | 745 | CustomersService.getJetMargin($scope.userProfileId).then(function(result) { |
742 | $scope.jetMarginList = result; | 746 | $scope.jetMarginList = result; |
743 | }) | 747 | }) |
744 | 748 | ||
745 | CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { | 749 | CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { |
746 | $scope.avgsMarginList = result; | 750 | $scope.avgsMarginList = result; |
747 | }) | 751 | }) |
748 | 752 | ||
749 | $scope.changePriceEmail = function(id, index) { | 753 | $scope.changePriceEmail = function(id, index) { |
750 | event.stopPropagation(); | 754 | event.stopPropagation(); |
751 | var contactId = id; | 755 | var contactId = id; |
752 | var statusData = "status=" + $scope.companyContactList[index].priceEmail; | 756 | var statusData = "status=" + $scope.companyContactList[index].priceEmail; |
753 | ViewcontactService.changePriceEmail(contactId, statusData).then(function(result) { | 757 | ViewcontactService.changePriceEmail(contactId, statusData).then(function(result) { |
754 | if (result.success) { | 758 | if (result.success) { |
755 | $('#toogleMail').css('display', 'block'); | 759 | $('#toogleMail').css('display', 'block'); |
756 | if ($scope.companyContactList[index].priceEmail == true) { | 760 | if ($scope.companyContactList[index].priceEmail == true) { |
757 | $scope.messageText = 'You have enabled price distribution for this contact'; | 761 | $scope.messageText = 'You have enabled price distribution for this contact'; |
758 | } else { | 762 | } else { |
759 | $scope.messageText = 'You have disabled price distribution for this contact'; | 763 | $scope.messageText = 'You have disabled price distribution for this contact'; |
760 | } | 764 | } |
761 | } | 765 | } |
762 | }) | 766 | }) |
763 | } | 767 | } |
764 | 768 | ||
765 | $scope.cancelToogle = function() { | 769 | $scope.cancelToogle = function() { |
766 | $('#toogleMail').css('display', 'none'); | 770 | $('#toogleMail').css('display', 'none'); |
767 | } | 771 | } |
768 | 772 | ||
769 | $scope.checkboxStatus = function(value) { | 773 | $scope.checkboxStatus = function(value) { |
770 | // console.log("checkbox",value) | 774 | // console.log("checkbox",value) |
771 | $scope.showUpdateBtn = true; | 775 | $scope.showUpdateBtn = true; |
772 | } | 776 | } |
773 | 777 | ||
774 | $scope.fuelercheckboxStatus = function(value) { | 778 | $scope.fuelercheckboxStatus = function(value) { |
775 | $('#fuelerchange').css('display', 'block'); | 779 | $('#fuelerchange').css('display', 'block'); |
776 | if (value == true) { | 780 | if (value == true) { |
777 | $scope.statusMessage = 'Please confirm! Enabling FuelerLinx for this customer will enable price distribution web services and disable price emails for the contacts in this company' | 781 | $scope.statusMessage = 'Please confirm! Enabling FuelerLinx for this customer will enable price distribution web services and disable price emails for the contacts in this company' |
778 | } else { | 782 | } else { |
779 | $scope.statusMessage = 'Please confirm! Disabling FuelerLinx for this customer will disable price distribution web services into their FuelerLinx account. If you proceed then remember to enable price emails for the appropriate contacts in this company.' | 783 | $scope.statusMessage = 'Please confirm! Disabling FuelerLinx for this customer will disable price distribution web services into their FuelerLinx account. If you proceed then remember to enable price emails for the appropriate contacts in this company.' |
780 | } | 784 | } |
781 | 785 | ||
782 | 786 | ||
783 | } | 787 | } |
784 | 788 | ||
785 | $scope.fuelerCancelStatus = function() { | 789 | $scope.fuelerCancelStatus = function() { |
786 | $('#fuelerchange').css('display', 'none'); | 790 | $('#fuelerchange').css('display', 'none'); |
787 | $scope.companyData.fuelerlinxCustomer = !$scope.companyData.fuelerlinxCustomer; | 791 | $scope.companyData.fuelerlinxCustomer = !$scope.companyData.fuelerlinxCustomer; |
788 | } | 792 | } |
789 | 793 | ||
790 | $scope.fuelerAcceptStatus = function() { | 794 | $scope.fuelerAcceptStatus = function() { |
791 | $('#fuelerchange').css('display', 'none'); | 795 | $('#fuelerchange').css('display', 'none'); |
792 | $scope.showLoader = true; | 796 | $scope.showLoader = true; |
793 | var statusData; | 797 | var statusData; |
794 | if ($scope.companyData.fuelerlinxCustomer == false) { | 798 | if ($scope.companyData.fuelerlinxCustomer == false) { |
795 | statusData = "status=true"; | 799 | statusData = "status=true"; |
796 | } else { | 800 | } else { |
797 | statusData = "status=false"; | 801 | statusData = "status=false"; |
798 | } | 802 | } |
799 | ViewCompanyService.fuelerPricingChange(companyId, statusData).then(function(result) { | 803 | ViewCompanyService.fuelerPricingChange(companyId, statusData).then(function(result) { |
800 | if (result.success) { | 804 | if (result.success) { |
801 | $scope.showLoader = false; | 805 | $scope.showLoader = false; |
802 | 806 | ||
803 | $scope.editData(); | 807 | $scope.editData(); |
804 | getContactList(); | 808 | getContactList(); |
805 | 809 | ||
806 | } | 810 | } |
807 | }) | 811 | }) |
808 | } | 812 | } |
809 | 813 | ||
810 | 814 | ||
811 | $scope.updateOmit = function(fuel, omit) { | 815 | $scope.updateOmit = function(fuel, omit) { |
812 | $scope.fuelData = {}; | 816 | $scope.fuelData = {}; |
813 | $scope.fuelData.expirationDate = new Date(fuel.expirationDate); | 817 | $scope.fuelData.expirationDate = new Date(fuel.expirationDate); |
814 | $scope.fuelData.customMarginId = fuel.id; | 818 | $scope.fuelData.customMarginId = fuel.id; |
815 | $scope.fuelData.omit = fuel.omit; | 819 | $scope.fuelData.omit = fuel.omit; |
816 | $scope.fuelData.papMargin = fuel.papMargin; | 820 | $scope.fuelData.papMargin = fuel.papMargin; |
817 | $scope.fuelData.papTotal = fuel.papTotal; | 821 | $scope.fuelData.papTotal = fuel.papTotal; |
818 | $scope.fuelData.cost = fuel.cost; | 822 | $scope.fuelData.cost = fuel.cost; |
819 | $scope.fuelData.companyId = $scope.compId ; | 823 | $scope.fuelData.companyId = $scope.compId ; |
820 | if($scope.fuelData.omit == true) | 824 | if($scope.fuelData.omit == true) |
821 | { | 825 | { |
822 | var customData = "companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId; | 826 | var customData = "companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId; |
823 | // console.log(".") | 827 | // console.log(".") |
824 | ViewCompanyService.omitAddCompanyFuel(customData).then(function(result) { | 828 | ViewCompanyService.omitAddCompanyFuel(customData).then(function(result) { |
825 | if (result.success) { | 829 | if (result.success) { |
826 | toastr.success('' + result.success + '', { | 830 | toastr.success('' + result.success + '', { |
827 | closeButton: true | 831 | closeButton: true |
828 | }) | 832 | }) |
829 | } else { | 833 | } else { |
830 | toastr.error('' + result.statusText + '', { | 834 | toastr.error('' + result.statusText + '', { |
831 | closeButton: true | 835 | closeButton: true |
832 | }) | 836 | }) |
833 | } | 837 | } |
834 | }) | 838 | }) |
835 | }else{ | 839 | }else{ |
836 | var data ="companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId; | 840 | var data ="companyId=" + $scope.fuelData.companyId + "&customMarginId=" + $scope.fuelData.customMarginId; |
837 | ViewCompanyService.omitDeleteCompanyFuel(data).then(function(result){ | 841 | ViewCompanyService.omitDeleteCompanyFuel(data).then(function(result){ |
838 | if (result.success) { | 842 | if (result.success) { |
839 | toastr.success('' + result.success + '', { | 843 | toastr.success('' + result.success + '', { |
840 | closeButton: true | 844 | closeButton: true |
841 | }) | 845 | }) |
842 | } else { | 846 | } else { |
843 | toastr.error('' + result.statusText + '', { | 847 | toastr.error('' + result.statusText + '', { |
844 | closeButton: true | 848 | closeButton: true |
845 | }) | 849 | }) |
846 | } | 850 | } |
847 | }) | 851 | }) |
848 | } | 852 | } |
849 | } | 853 | } |
850 | 854 | ||
851 | 855 | ||
852 | //--fuel type based on tail is not in use-- | 856 | //--fuel type based on tail is not in use-- |
853 | // $scope.aircraftData = {} | 857 | // $scope.aircraftData = {} |
854 | /*$scope.checkJetWithTail = function(tail, index) { | 858 | /*$scope.checkJetWithTail = function(tail, index) { |
855 | 859 | ||
856 | console.log("tail==============",tail, index) | 860 | console.log("tail==============",tail, index) |
857 | ViewCompanyService.checkJetType(tail).then(function(result) { | 861 | ViewCompanyService.checkJetType(tail).then(function(result) { |
858 | console.log("result",result) | 862 | console.log("result",result) |
859 | if (result.jetA == "true") { | 863 | if (result.jetA == "true") { |
860 | $scope.jetShow[index] = false; | 864 | $scope.jetShow[index] = false; |
861 | $scope.marginShow[index] = true; | 865 | $scope.marginShow[index] = true; |
862 | } else { | 866 | } else { |
863 | $scope.jetShow[index] = true; | 867 | $scope.jetShow[index] = true; |
864 | $scope.marginShow[index] = false; | 868 | $scope.marginShow[index] = false; |
865 | } | 869 | } |
866 | }) | 870 | }) |
867 | }*/ | 871 | }*/ |
868 | 872 | ||
869 | 873 | ||
870 | /*add a fuel order*/ | 874 | /*add a fuel order*/ |
871 | 875 | ||
872 | 876 | ||
873 | $scope.getOrders = function() { | 877 | $scope.getOrders = function() { |
874 | fuelOrdersService.getOrders().then(function(result) { | 878 | fuelOrdersService.getOrders().then(function(result) { |
875 | 879 | ||
876 | $scope.orderdata = result; | 880 | $scope.orderdata = result; |
877 | for (var i = 0; i < $scope.orderdata.length; i++) { | 881 | for (var i = 0; i < $scope.orderdata.length; i++) { |
878 | $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); | 882 | $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); |
879 | 883 | ||
880 | // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear() | 884 | // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear() |
881 | var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear() | 885 | var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear() |
882 | // str = str.slice(4,16) | 886 | // str = str.slice(4,16) |
883 | $scope.orderdata[i].upliftDateString = str | 887 | $scope.orderdata[i].upliftDateString = str |
884 | // console.log(str); | 888 | // console.log(str); |
885 | 889 | ||
886 | } | 890 | } |
887 | 891 | ||
888 | $scope.displayFuelOrderList = new NgTableParams({ | 892 | $scope.displayFuelOrderList = new NgTableParams({ |
889 | page: 1, | 893 | page: 1, |
890 | count: 10, | 894 | count: 10, |
891 | }, { | 895 | }, { |
892 | data: $scope.orderdata | 896 | data: $scope.orderdata |
893 | }); | 897 | }); |
894 | $(document).ready(function() { | 898 | $(document).ready(function() { |
895 | var myselect = document.getElementsByClassName('colorfulSelectbox'); | 899 | var myselect = document.getElementsByClassName('colorfulSelectbox'); |
896 | 900 | ||
897 | for (var i = 0; i < myselect.length; i++) { | 901 | for (var i = 0; i < myselect.length; i++) { |
898 | var colourIndex = $(myselect[i]).prop('selectedIndex'); | 902 | var colourIndex = $(myselect[i]).prop('selectedIndex'); |
899 | colourIndex = colourIndex + 1; | 903 | colourIndex = colourIndex + 1; |
900 | // console.log(colourIndex); | 904 | // console.log(colourIndex); |
901 | var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color'); | 905 | var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color'); |
902 | $(myselect[i]).css('background-color', getColor); | 906 | $(myselect[i]).css('background-color', getColor); |
903 | // console.log('colour', getColor); | 907 | // console.log('colour', getColor); |
904 | myselect[i].blur(); | 908 | myselect[i].blur(); |
905 | } | 909 | } |
906 | 910 | ||
907 | }) | 911 | }) |
908 | 912 | ||
909 | }) | 913 | }) |
910 | } | 914 | } |
911 | 915 | ||
912 | $scope.getOrders(); | 916 | $scope.getOrders(); |
913 | 917 | ||
914 | $scope.tiervalue=function(){ | 918 | $scope.tiervalue=function(){ |
915 | $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; | 919 | $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; |
916 | } | 920 | } |
917 | 921 | ||
918 | $scope.setCost = function(cost){ | 922 | $scope.setCost = function(cost){ |
919 | if(cost != null) { | 923 | if(cost != null) { |
920 | var obj =JSON.parse(cost); | 924 | var obj =JSON.parse(cost); |
921 | $scope.order.fboCost = obj.cost; | 925 | $scope.order.fboCost = obj.cost; |
922 | } | 926 | } |
923 | } | 927 | } |
924 | 928 | ||
925 | $scope.cancelOrder = function() { | 929 | $scope.cancelOrder = function() { |
926 | $scope.order = {}; | 930 | $scope.order = {}; |
927 | } | 931 | } |
928 | 932 | ||
929 | $scope.dispatchFuel = function(){ | 933 | $scope.dispatchFuel = function(){ |
930 | $scope.showLoader = true; | 934 | $scope.showLoader = true; |
931 | $scope.order.companyId = $scope.compId; | 935 | $scope.order.companyId = $scope.compId; |
932 | if ($scope.order.upliftDate != '') { | 936 | if ($scope.order.upliftDate != '') { |
933 | var currentDate = new Date(); | 937 | var currentDate = new Date(); |
934 | var hours = currentDate.getHours(); | 938 | var hours = currentDate.getHours(); |
935 | var min = currentDate.getMinutes(); | 939 | var min = currentDate.getMinutes(); |
936 | var sec = currentDate.getSeconds(); | 940 | var sec = currentDate.getSeconds(); |
937 | $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; | 941 | $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; |
938 | $scope.order.upliftDate = new Date($scope.order.upliftDate); | 942 | $scope.order.upliftDate = new Date($scope.order.upliftDate); |
939 | $scope.order.upliftDate = $scope.order.upliftDate.getTime(); | 943 | $scope.order.upliftDate = $scope.order.upliftDate.getTime(); |
940 | } | 944 | } |
941 | $scope.order.status = 'pending'; | 945 | $scope.order.status = 'pending'; |
942 | var obj =JSON.parse($scope.order.priceQuote); | 946 | var obj =JSON.parse($scope.order.priceQuote); |
943 | $scope.order.priceQuote = obj.papTotal; | 947 | $scope.order.priceQuote = obj.papTotal; |
944 | $scope.order.fboCost = obj.cost; | 948 | $scope.order.fboCost = obj.cost; |
945 | $scope.order.total = obj.papTotal * $scope.order.volume; | 949 | $scope.order.total = obj.papTotal * $scope.order.volume; |
946 | var aircraftObj =JSON.parse($scope.order.aircraftName); | 950 | var aircraftObj =JSON.parse($scope.order.aircraftName); |
947 | $scope.order.aircraftName = aircraftObj.tail; | 951 | $scope.order.aircraftName = aircraftObj.tail; |
948 | $scope.order.make = aircraftObj.make; | 952 | $scope.order.make = aircraftObj.make; |
949 | $scope.order.model = aircraftObj.model; | 953 | $scope.order.model = aircraftObj.model; |
950 | $scope.dispatchOrder.fuelOrderList.push($scope.order); | 954 | $scope.dispatchOrder.fuelOrderList.push($scope.order); |
951 | enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { | 955 | enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { |
952 | $scope.showLoader = false; | 956 | $scope.showLoader = false; |
953 | $scope.order = {}; | 957 | $scope.order = {}; |
954 | $('#demo-modal-4').css('display', ''); | 958 | $('#demo-modal-4').css('display', ''); |
955 | toastr.success('Fuel Order Dispatched Successfully', { | 959 | toastr.success('Fuel Order Dispatched Successfully', { |
956 | closeButton: true | 960 | closeButton: true |
957 | }) | 961 | }) |
958 | }) | 962 | }) |
959 | } | 963 | } |
960 | 964 | ||
961 | $scope.addTotal = function(value, valueOf) { | 965 | $scope.addTotal = function(value, valueOf) { |
962 | if (valueOf == 'v') { | 966 | if (valueOf == 'v') { |
963 | $scope.order.total = value * $scope.order.invoiced | 967 | $scope.order.total = value * $scope.order.invoiced |
964 | } else if (valueOf == 'i') { | 968 | } else if (valueOf == 'i') { |
965 | $scope.order.total = $scope.order.volume * value | 969 | $scope.order.total = $scope.order.volume * value |
966 | } | 970 | } |
967 | } | 971 | } |
968 | 972 | ||
969 | $scope.getAircraft = function(company) { | 973 | $scope.getAircraft = function(company) { |
970 | $scope.selectedCompanyName = company; | 974 | $scope.selectedCompanyName = company; |
971 | 975 | ||
972 | if ($scope.companyData.margin != null && $scope.companyData.marginAVGAS != null) { | 976 | if ($scope.companyData.margin != null && $scope.companyData.marginAVGAS != null) { |
973 | fuelOrdersService.getFuelCost($scope.companyData.id).then(function(margins) { | 977 | fuelOrdersService.getFuelCost($scope.companyData.id).then(function(margins) { |
974 | $scope.marginList = margins; | 978 | $scope.marginList = margins; |
975 | //console.log('$scope.marginList', $scope.marginList); | 979 | //console.log('$scope.marginList', $scope.marginList); |
976 | }) | 980 | }) |
977 | } else if ($scope.companyData.margin != null || $scope.companyData.marginAVGAS == null) { | 981 | } else if ($scope.companyData.margin != null || $scope.companyData.marginAVGAS == null) { |
978 | fuelOrdersService.getATypeFuelPricing($scope.companyData.id).then(function(margins) { | 982 | fuelOrdersService.getATypeFuelPricing($scope.companyData.id).then(function(margins) { |
979 | $scope.marginList = margins; | 983 | $scope.marginList = margins; |
980 | }) | 984 | }) |
981 | } else if ($scope.companyData.margin == null || $scope.companyData.marginAVGAS != null) { | 985 | } else if ($scope.companyData.margin == null || $scope.companyData.marginAVGAS != null) { |
982 | fuelOrdersService.getVTypeFuelPricing($scope.companyData.id).then(function(margins) { | 986 | fuelOrdersService.getVTypeFuelPricing($scope.companyData.id).then(function(margins) { |
983 | $scope.marginList = margins; | 987 | $scope.marginList = margins; |
984 | }) | 988 | }) |
985 | } | 989 | } |
986 | 990 | ||
987 | 991 | ||
988 | $scope.selectedCompanyId = $scope.companyData.id; | 992 | $scope.selectedCompanyId = $scope.companyData.id; |
989 | $scope.marginId = $scope.companyData.margin.id; | 993 | $scope.marginId = $scope.companyData.margin.id; |
990 | if ($scope.selectedCompanyId != '') { | 994 | if ($scope.selectedCompanyId != '') { |
991 | fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { | 995 | fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { |
992 | $scope.aircraftList = aircraft; | 996 | $scope.aircraftList = aircraft; |
993 | }) | 997 | }) |
994 | } | 998 | } |
995 | if ($scope.marginId != '') { | 999 | if ($scope.marginId != '') { |
996 | fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) { | 1000 | fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) { |
997 | $scope.tierList = tiers; | 1001 | $scope.tierList = tiers; |
998 | // $scope.showLoader = false; | 1002 | // $scope.showLoader = false; |
999 | }) | 1003 | }) |
1000 | } | 1004 | } |
1001 | 1005 | ||
1002 | } | 1006 | } |
1003 | 1007 | ||
1004 | $scope.setCost = function(cost) { | 1008 | $scope.setCost = function(cost) { |
1005 | // console.log(cost); | 1009 | // console.log(cost); |
1006 | if (cost != null) { | 1010 | if (cost != null) { |
1007 | var obj = JSON.parse(cost); | 1011 | var obj = JSON.parse(cost); |
1008 | // console.log("0bj",obj) | 1012 | // console.log("0bj",obj) |
1009 | $scope.order.fboCost = obj.cost; | 1013 | $scope.order.fboCost = obj.cost; |
1010 | } | 1014 | } |
1011 | 1015 | ||
1012 | } | 1016 | } |
1013 | 1017 | ||
1014 | $scope.sourceList = [{ | 1018 | $scope.sourceList = [{ |
1015 | source: "Direct Jet-A" | 1019 | source: "Direct Jet-A" |
1016 | }, { | 1020 | }, { |
1017 | source: "Direct AVGAS 100LL" | 1021 | source: "Direct AVGAS 100LL" |
1018 | }]; | 1022 | }]; |
1019 | $scope.cancelData = function() { | 1023 | $scope.cancelData = function() { |
1020 | $('#demo-modal-4').css('display', ''); | 1024 | $('#demo-modal-4').css('display', ''); |
1021 | } | 1025 | } |
1022 | 1026 | ||
1023 | $scope.setFuel = function() { | 1027 | $scope.setFuel = function() { |
1024 | $('#demo-modal-4').css('display', 'block'); | 1028 | $('#demo-modal-4').css('display', 'block'); |
1025 | 1029 | ||
1026 | } | 1030 | } |
1027 | 1031 | ||
1028 | /*delete company*/ | 1032 | /*delete company*/ |
1029 | var deletecompanyId = ""; | 1033 | var deletecompanyId = ""; |
1030 | $scope.deleteComp = function(companyDataid) { | 1034 | $scope.deleteComp = function(companyDataid) { |
1031 | $('#delete2').css('display', 'block'); | 1035 | $('#delete2').css('display', 'block'); |
1032 | //console.log("asda",companyDataid) | 1036 | //console.log("asda",companyDataid) |
1033 | deletecompanyId = companyDataid; | 1037 | deletecompanyId = companyDataid; |
1034 | } | 1038 | } |
1035 | $scope.aircraftIdx = ''; | 1039 | $scope.aircraftIdx = ''; |
1036 | $scope.checkTail = function(tail, idx){ | 1040 | $scope.checkTail = function(tail, idx){ |
1037 | var data = "tail=" + tail + "&id=" + companyId; | 1041 | var data = "tail=" + tail + "&id=" + companyId; |
1038 | $scope.aircraftIdx = idx; | 1042 | $scope.aircraftIdx = idx; |
1039 | ViewCompanyService.checkTail(data).then(function(result) { | 1043 | ViewCompanyService.checkTail(data).then(function(result) { |
1040 | if(result.error) { | 1044 | if(result.error) { |
1041 | $scope.aircraftMessage = result.error; | 1045 | $scope.aircraftMessage = result.error; |
1042 | $scope.openAddAirCraftError(); | 1046 | $scope.openAddAirCraftError(); |
1043 | } else if(result.warning) { | 1047 | } else if(result.warning) { |
1044 | $scope.aircraftMessage = result.warning; | 1048 | $scope.aircraftMessage = result.warning; |
1045 | $scope.openAddAirCraftWarning(); | 1049 | $scope.openAddAirCraftWarning(); |
1046 | } | 1050 | } |
1047 | }) | 1051 | }) |
1048 | } | 1052 | } |
1049 | 1053 | ||
1050 | $scope.openAddAirCraftError = function() { | 1054 | $scope.openAddAirCraftError = function() { |
1051 | $('#addAirCraftError').css('display', 'block'); | 1055 | $('#addAirCraftError').css('display', 'block'); |
1052 | } | 1056 | } |
1053 | 1057 | ||
1054 | $scope.openAddAirCraftWarning = function() { | 1058 | $scope.openAddAirCraftWarning = function() { |
1055 | $('#addAirCraftWarning').css('display', 'block'); | 1059 | $('#addAirCraftWarning').css('display', 'block'); |
1056 | } | 1060 | } |
1057 | $scope.acceptAirCraftError = function() { | 1061 | $scope.acceptAirCraftError = function() { |
1058 | $('#addAirCraftWarning').css('display', 'none'); | 1062 | $('#addAirCraftWarning').css('display', 'none'); |
1059 | } | 1063 | } |
1060 | 1064 | ||
1061 | $scope.cancelAirCraftError = function() { | 1065 | $scope.cancelAirCraftError = function() { |
1062 | $scope.aircraftDetails[$scope.aircraftIdx].tail = ''; | 1066 | $scope.aircraftDetails[$scope.aircraftIdx].tail = ''; |
1063 | $('#addAirCraftWarning').css('display', 'none'); | 1067 | $('#addAirCraftWarning').css('display', 'none'); |
1064 | $('#addAirCraftError').css('display', 'none'); | 1068 | $('#addAirCraftError').css('display', 'none'); |
1065 | } | 1069 | } |
1066 | 1070 | ||
1067 | $scope.deleteCompanyData = function() { | 1071 | $scope.deleteCompanyData = function() { |
1068 | ViewCompanyService.deleteCompany(deletecompanyId).then(function(result) { | 1072 | ViewCompanyService.deleteCompany(deletecompanyId).then(function(result) { |
1069 | 1073 | ||
1070 | $('#delete2').css('display', 'none'); | 1074 | $('#delete2').css('display', 'none'); |
1071 | if (result.success) { | 1075 | if (result.success) { |
1072 | toastr.success('' + result.success + '', { | 1076 | toastr.success('' + result.success + '', { |
1073 | closeButton: true | 1077 | closeButton: true |
1074 | 1078 | ||
1075 | }) | 1079 | }) |
1076 | } else { | 1080 | } else { |
1077 | toastr.error('' + result.statusText + '', { | 1081 | toastr.error('' + result.statusText + '', { |
1078 | closeButton: true | 1082 | closeButton: true |
1079 | 1083 | ||
1080 | }) | 1084 | }) |
1081 | } | 1085 | } |
1082 | $state.go('app.customers') | 1086 | $state.go('app.customers') |
1083 | }) | 1087 | }) |
1084 | } | 1088 | } |
1085 | $scope.cancelDelete = function() { | 1089 | $scope.cancelDelete = function() { |
1086 | $('#delete2').css('display', 'none'); | 1090 | $('#delete2').css('display', 'none'); |
1087 | } | 1091 | } |
1088 | 1092 | ||
1089 | 1093 | ||
1090 | $scope.editJetMargin = function(aircraftData, type) { | 1094 | $scope.editJetMargin = function(aircraftData, type) { |
1091 | $scope.showLoader = true; | 1095 | $scope.showLoader = true; |
1092 | if (type == 'jet') { | 1096 | if (type == 'jet') { |
1093 | 1097 | ||
1094 | var aircraftdataMargin = "marginId=" + aircraftData.aircraftsMargin.id + "&type=" + type; | 1098 | var aircraftdataMargin = "marginId=" + aircraftData.aircraftsMargin.id + "&type=" + type; |
1095 | 1099 | ||
1096 | } else { | 1100 | } else { |
1097 | var aircraftdataMargin = "marginId=" + aircraftData.aircraftsAVGASMargin.id + "&type=" + type; | 1101 | var aircraftdataMargin = "marginId=" + aircraftData.aircraftsAVGASMargin.id + "&type=" + type; |
1098 | } | 1102 | } |
1099 | 1103 | ||
1100 | var id = aircraftData.id; | 1104 | var id = aircraftData.id; |
1101 | ViewCompanyService.updateAircraftMargin(aircraftdataMargin, id).then(function(result) { | 1105 | ViewCompanyService.updateAircraftMargin(aircraftdataMargin, id).then(function(result) { |
1102 | if (result != null && result.success) { | 1106 | if (result != null && result.success) { |
1103 | $scope.showLoader = false; | 1107 | $scope.showLoader = false; |
1104 | toastr.success('' + result.success + '', { | 1108 | toastr.success('' + result.success + '', { |
1105 | closeButton: true | 1109 | closeButton: true |
1106 | }) | 1110 | }) |
1107 | // getAircraftWithMarginList(); | 1111 | // getAircraftWithMarginList(); |
1108 | getAircraftList(); | 1112 | getAircraftList(); |
1109 | } else { | 1113 | } else { |
1110 | $scope.showLoader = false; | 1114 | $scope.showLoader = false; |
1111 | toastr.error('' + result.statusText + '', { | 1115 | toastr.error('' + result.statusText + '', { |
1112 | closeButton: true | 1116 | closeButton: true |
1113 | }) | 1117 | }) |
1114 | } | 1118 | } |
1115 | }) | 1119 | }) |
1116 | } | 1120 | } |
1117 | 1121 | ||
1118 | 1122 | ||
1119 | /* //not used currently | 1123 | /* //not used currently |
1120 | function getAircraftWithMarginList() { | 1124 | function getAircraftWithMarginList() { |
1121 | ViewCompanyService.getJetAMargin(companyId).then(function(result) { | 1125 | ViewCompanyService.getJetAMargin(companyId).then(function(result) { |
1122 | $scope.contactAircraftList = result; | 1126 | $scope.contactAircraftList = result; |
1123 | for (var i = 0; i < $scope.contactAircraftList.length; i++) { | 1127 | for (var i = 0; i < $scope.contactAircraftList.length; i++) { |
1124 | if ($scope.contactAircraftList[i].aircraftsMargin != null) { | 1128 | if ($scope.contactAircraftList[i].aircraftsMargin != null) { |
1125 | $scope.aircraftmargins.push({ | 1129 | $scope.aircraftmargins.push({ |
1126 | 'id': $scope.contactAircraftList[i].aircraftsMargin.id | 1130 | 'id': $scope.contactAircraftList[i].aircraftsMargin.id |
1127 | }) | 1131 | }) |
1128 | } | 1132 | } |
1129 | } | 1133 | } |
1130 | if ($scope.aircraftmargins.length > 0) { | 1134 | if ($scope.aircraftmargins.length > 0) { |
1131 | for (var i = 0; i < $scope.aircraftmargins.length; i++) { | 1135 | for (var i = 0; i < $scope.aircraftmargins.length; i++) { |
1132 | if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) { | 1136 | if ($scope.aircraftmargins[i].id != $scope.companyData.masterMargin) { |
1133 | $scope.multiple = true; | 1137 | $scope.multiple = true; |
1134 | $scope.multipleMsg = true; | 1138 | $scope.multipleMsg = true; |
1135 | if ($scope.multiple) { | 1139 | if ($scope.multiple) { |
1136 | $scope.companyData.masterMargin = "multiple"; | 1140 | $scope.companyData.masterMargin = "multiple"; |
1137 | } | 1141 | } |
1138 | } | 1142 | } |
1139 | } | 1143 | } |
1140 | } | 1144 | } |
1141 | }) | 1145 | }) |
1142 | }*/ | 1146 | }*/ |
1143 | 1147 | ||
1144 | 1148 | ||
1145 | }]); | 1149 | }]); |