Commit 39a850f316df3606b429c81de5a69a62180ad48d
1 parent
10e8f79f84
Exists in
master
total calculation
Showing
3 changed files
with
4 additions
and
10 deletions
Show diff stats
app/partials/customers/customers.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 | .controller('customersController', [ '$scope', '$rootScope', '$uibModal', '$filter', '$http', '$state', 'CustomersService', 'ViewCompanyService', 'NgTableParams', 'fuelOrdersService', 'enterFuelOrderService', customersController ]); | 5 | .controller('customersController', [ '$scope', '$rootScope', '$uibModal', '$filter', '$http', '$state', 'CustomersService', 'ViewCompanyService', 'NgTableParams', 'fuelOrdersService', 'enterFuelOrderService', customersController ]); |
6 | 6 | ||
7 | function customersController($scope, $rootScope, $uibModal, $filter, $http, $state, CustomersService, ViewCompanyService, NgTableParams, fuelOrdersService, enterFuelOrderService) { | 7 | function customersController($scope, $rootScope, $uibModal, $filter, $http, $state, CustomersService, ViewCompanyService, NgTableParams, fuelOrdersService, enterFuelOrderService) { |
8 | $(document).ready(function() { | 8 | $(document).ready(function() { |
9 | // $('#example').DataTable(); | 9 | // $('#example').DataTable(); |
10 | }); | 10 | }); |
11 | $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')) | 11 | $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')) |
12 | $scope.reset2 = function() { | 12 | $scope.reset2 = function() { |
13 | $("input").val(""); | 13 | $("input").val(""); |
14 | $scope.removeMarginValidation(); | 14 | $scope.removeMarginValidation(); |
15 | } | 15 | } |
16 | 16 | ||
17 | $scope.order = {}; | 17 | $scope.order = {}; |
18 | $scope.order.upliftDate = ''; | 18 | $scope.order.upliftDate = ''; |
19 | $scope.data = {}; | 19 | $scope.data = {}; |
20 | $scope.aircraft = {}; | 20 | $scope.aircraft = {}; |
21 | $scope.data.activate = true; | 21 | $scope.data.activate = true; |
22 | $scope.showLoader = true; | 22 | $scope.showLoader = true; |
23 | $scope.jetShow = []; | 23 | $scope.jetShow = []; |
24 | $scope.marginShow = []; | 24 | $scope.marginShow = []; |
25 | 25 | ||
26 | $scope.jetShow[0] = true; | 26 | $scope.jetShow[0] = true; |
27 | $scope.marginShow[0] = true; | 27 | $scope.marginShow[0] = true; |
28 | $scope.dispatchOrder = {}; | 28 | $scope.dispatchOrder = {}; |
29 | $scope.dispatchOrder.fuelOrderList = []; | 29 | $scope.dispatchOrder.fuelOrderList = []; |
30 | $scope.statusFilterOptions = []; | 30 | $scope.statusFilterOptions = []; |
31 | $scope.companyList = {}; | 31 | $scope.companyList = {}; |
32 | $scope.statusFilterOptions.push({ | 32 | $scope.statusFilterOptions.push({ |
33 | 'id' : '', | 33 | 'id' : '', |
34 | 'title' : 'Show All' | 34 | 'title' : 'Show All' |
35 | }, { | 35 | }, { |
36 | 'id' : 'pending', | 36 | 'id' : 'pending', |
37 | 'title' : 'Pending' | 37 | 'title' : 'Pending' |
38 | }, { | 38 | }, { |
39 | 'id' : 'invoiced', | 39 | 'id' : 'invoiced', |
40 | 'title' : 'Invoiced' | 40 | 'title' : 'Invoiced' |
41 | }, { | 41 | }, { |
42 | 'id' : 'paid', | 42 | 'id' : 'paid', |
43 | 'title' : 'Paid' | 43 | 'title' : 'Paid' |
44 | }, { | 44 | }, { |
45 | 'id' : 'cancelled', | 45 | 'id' : 'cancelled', |
46 | 'title' : 'Cancelled' | 46 | 'title' : 'Cancelled' |
47 | }, { | 47 | }, { |
48 | 'id' : 'archived', | 48 | 'id' : 'archived', |
49 | 'title' : 'Archived' | 49 | 'title' : 'Archived' |
50 | } | 50 | } |
51 | 51 | ||
52 | ); | 52 | ); |
53 | 53 | ||
54 | /*function getAllCompanies(){ | 54 | /*function getAllCompanies(){ |
55 | CustomersService.getAllCompanies().then(function(result) { | 55 | CustomersService.getAllCompanies().then(function(result) { |
56 | $scope.companyList = result; | 56 | $scope.companyList = result; |
57 | for(var i=0; i<$scope.companyList.length; i++){ | 57 | for(var i=0; i<$scope.companyList.length; i++){ |
58 | $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; | 58 | $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; |
59 | } | 59 | } |
60 | }) | 60 | }) |
61 | 61 | ||
62 | }*/ | 62 | }*/ |
63 | 63 | ||
64 | $scope.statusFilter = [ | 64 | $scope.statusFilter = [ |
65 | { | 65 | { |
66 | id : "", | 66 | id : "", |
67 | title : "Show All" | 67 | title : "Show All" |
68 | }, | 68 | }, |
69 | { | 69 | { |
70 | id : "true", | 70 | id : "true", |
71 | title : "Active" | 71 | title : "Active" |
72 | }, | 72 | }, |
73 | { | 73 | { |
74 | id : "false", | 74 | id : "false", |
75 | title : "Inactive" | 75 | title : "Inactive" |
76 | } | 76 | } |
77 | ] | 77 | ] |
78 | 78 | ||
79 | function getAllCompanies() { | 79 | function getAllCompanies() { |
80 | CustomersService.getAllCompanies().then(function(result) { | 80 | CustomersService.getAllCompanies().then(function(result) { |
81 | $scope.companyList = result; | 81 | $scope.companyList = result; |
82 | for (var i = 0; i < $scope.companyList.length; i++) { | 82 | for (var i = 0; i < $scope.companyList.length; i++) { |
83 | if ($scope.companyList[i].companyContact != null) { | 83 | if ($scope.companyList[i].companyContact != null) { |
84 | if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) { | 84 | if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) { |
85 | $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber; | 85 | $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | if ($scope.companyList[i].primaryContact != null) { | 88 | if ($scope.companyList[i].primaryContact != null) { |
89 | if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) { | 89 | if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) { |
90 | $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName; | 90 | $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName; |
91 | } | 91 | } |
92 | } | 92 | } |
93 | if ($scope.companyList[i].margin != null) { | 93 | if ($scope.companyList[i].margin != null) { |
94 | if ($scope.companyList[i].margin.marginName != null) { | 94 | if ($scope.companyList[i].margin.marginName != null) { |
95 | $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; | 95 | $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | } | 98 | } |
99 | $scope.displayCompanyList = new NgTableParams({ | 99 | $scope.displayCompanyList = new NgTableParams({ |
100 | page : 1, | 100 | page : 1, |
101 | count : 10, | 101 | count : 10, |
102 | }, { | 102 | }, { |
103 | data : $scope.companyList | 103 | data : $scope.companyList |
104 | }); | 104 | }); |
105 | $scope.showLoader = false; | 105 | $scope.showLoader = false; |
106 | }) | 106 | }) |
107 | } | 107 | } |
108 | 108 | ||
109 | getAllCompanies(); | 109 | getAllCompanies(); |
110 | 110 | ||
111 | $scope.editMargin = function(customer) { | 111 | $scope.editMargin = function(customer) { |
112 | //console.log('customer', customer); | 112 | //console.log('customer', customer); |
113 | $scope.showLoader = true; | 113 | $scope.showLoader = true; |
114 | event.stopPropagation(); | 114 | event.stopPropagation(); |
115 | 115 | ||
116 | var companyMargin = "companyName=" + customer.companyName + "&masterMargin=" + customer.masterMargin | 116 | var companyMargin = "companyName=" + customer.companyName + "&masterMargin=" + customer.masterMargin |
117 | + "&addressOne=" + customer.addressOne + "&addressTwo=" + customer.addressTwo + "&city=" + customer.city + "&state=" | 117 | + "&addressOne=" + customer.addressOne + "&addressTwo=" + customer.addressTwo + "&city=" + customer.city + "&state=" |
118 | + customer.state + "&country=" + customer.country + "&zipcode=" + customer.zipcode + "&internalNote=" | 118 | + customer.state + "&country=" + customer.country + "&zipcode=" + customer.zipcode + "&internalNote=" |
119 | + customer.internalNote + "&certificateType=" + customer.certificateType + "&baseTenant=" + customer.baseTenant | 119 | + customer.internalNote + "&certificateType=" + customer.certificateType + "&baseTenant=" + customer.baseTenant |
120 | + "&fuelerlinxCustomer=" + customer.fuelerlinxCustomer + "&contractFuelVendor=" + customer.contractFuelVendor | 120 | + "&fuelerlinxCustomer=" + customer.fuelerlinxCustomer + "&contractFuelVendor=" + customer.contractFuelVendor |
121 | + "&activate=" + customer.activate + "&baseIcao=" + customer.baseIcao + "&companyId=" + customer.id; | 121 | + "&activate=" + customer.activate + "&baseIcao=" + customer.baseIcao + "&companyId=" + customer.id; |
122 | 122 | ||
123 | ViewCompanyService.updateCompany(companyMargin).then(function(result) { | 123 | ViewCompanyService.updateCompany(companyMargin).then(function(result) { |
124 | if (result != null && result.success) { | 124 | if (result != null && result.success) { |
125 | $scope.showLoader = false; | 125 | $scope.showLoader = false; |
126 | toastr.success('' + result.success + '', { | 126 | toastr.success('' + result.success + '', { |
127 | closeButton : true | 127 | closeButton : true |
128 | }) | 128 | }) |
129 | getAllCompanies(); | 129 | getAllCompanies(); |
130 | } else { | 130 | } else { |
131 | $scope.showLoader = false; | 131 | $scope.showLoader = false; |
132 | toastr.error('' + result.statusText + '', { | 132 | toastr.error('' + result.statusText + '', { |
133 | closeButton : true | 133 | closeButton : true |
134 | }) | 134 | }) |
135 | } | 135 | } |
136 | }) | 136 | }) |
137 | } | 137 | } |
138 | 138 | ||
139 | getData(); | 139 | getData(); |
140 | function getData() { | 140 | function getData() { |
141 | $scope.showLoader = true; | 141 | $scope.showLoader = true; |
142 | CustomersService.getAircraftMake().then(function(result) { | 142 | CustomersService.getAircraftMake().then(function(result) { |
143 | //console.log("==aircrafts===",result) | 143 | //console.log("==aircrafts===",result) |
144 | $scope.aircraftMakeList = result; | 144 | $scope.aircraftMakeList = result; |
145 | $scope.showLoader = false; | 145 | $scope.showLoader = false; |
146 | }) | 146 | }) |
147 | } | 147 | } |
148 | // CustomersService.getMargin().then(function(result) { | 148 | // CustomersService.getMargin().then(function(result) { |
149 | // $scope.marginList = result; | 149 | // $scope.marginList = result; |
150 | // }) | 150 | // }) |
151 | $scope.marginFilterOptions = []; | 151 | $scope.marginFilterOptions = []; |
152 | CustomersService.getJetMargin($scope.userProfileId).then(function(result) { | 152 | CustomersService.getJetMargin($scope.userProfileId).then(function(result) { |
153 | $scope.showLoader = true; | 153 | $scope.showLoader = true; |
154 | $scope.jetMarginList = result; | 154 | $scope.jetMarginList = result; |
155 | //console.log("jet margin",result,$scope.userProfileId) | 155 | //console.log("jet margin",result,$scope.userProfileId) |
156 | $scope.marginFilterOptions.push({ | 156 | $scope.marginFilterOptions.push({ |
157 | 'id' : '', | 157 | 'id' : '', |
158 | 'title' : 'Show All' | 158 | 'title' : 'Show All' |
159 | }); | 159 | }); |
160 | for (var i = 0; i < result.length; i++) { | 160 | for (var i = 0; i < result.length; i++) { |
161 | $scope.marginFilterOptions.push({ | 161 | $scope.marginFilterOptions.push({ |
162 | 'id' : result[i].id, | 162 | 'id' : result[i].id, |
163 | 'title' : result[i].marginName | 163 | 'title' : result[i].marginName |
164 | }) | 164 | }) |
165 | } | 165 | } |
166 | $scope.showLoader = false; | 166 | $scope.showLoader = false; |
167 | }) | 167 | }) |
168 | 168 | ||
169 | CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { | 169 | CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { |
170 | $scope.avgsMarginList = result; | 170 | $scope.avgsMarginList = result; |
171 | // console.log('avgsMarginList',result) | 171 | // console.log('avgsMarginList',result) |
172 | }) | 172 | }) |
173 | 173 | ||
174 | 174 | ||
175 | $scope.showCompanyError = false; | 175 | $scope.showCompanyError = false; |
176 | $scope.showMarginError = false; | 176 | $scope.showMarginError = false; |
177 | 177 | ||
178 | $scope.removeValidation = function() { | 178 | $scope.removeValidation = function() { |
179 | $scope.showCompanyError = false; | 179 | $scope.showCompanyError = false; |
180 | $('.companyNameInput').removeClass('customErrorInput'); | 180 | $('.companyNameInput').removeClass('customErrorInput'); |
181 | if ($scope.data.companyName == 'undefined' || $scope.data.companyName == '') { | 181 | if ($scope.data.companyName == 'undefined' || $scope.data.companyName == '') { |
182 | $('.companyNameInput').addClass('customErrorInput'); | 182 | $('.companyNameInput').addClass('customErrorInput'); |
183 | $scope.showCompanyError = true; | 183 | $scope.showCompanyError = true; |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | $scope.removeMarginValidation = function() { | 187 | $scope.removeMarginValidation = function() { |
188 | $scope.showMarginError = false; | 188 | $scope.showMarginError = false; |
189 | $('.marginSelectBox').removeClass('customErrorInput'); | 189 | $('.marginSelectBox').removeClass('customErrorInput'); |
190 | } | 190 | } |
191 | 191 | ||
192 | var companyData; | 192 | var companyData; |
193 | $scope.addFirstData = function(sel, step) { | 193 | $scope.addFirstData = function(sel, step) { |
194 | $scope.showLoader = true; | 194 | $scope.showLoader = true; |
195 | if ($scope.data.companyName == undefined) { | 195 | if ($scope.data.companyName == undefined) { |
196 | $scope.showCompanyError = true; | 196 | $scope.showCompanyError = true; |
197 | $('.companyNameInput').addClass('customErrorInput'); | 197 | $('.companyNameInput').addClass('customErrorInput'); |
198 | } else if ($scope.data.masterMargin == undefined) { | 198 | } else if ($scope.data.masterMargin == undefined) { |
199 | $scope.showMarginError = true; | 199 | $scope.showMarginError = true; |
200 | $('.marginSelectBox').addClass('customErrorInput'); | 200 | $('.marginSelectBox').addClass('customErrorInput'); |
201 | } else { | 201 | } else { |
202 | $scope.aircraftDetails = [ { | 202 | $scope.aircraftDetails = [ { |
203 | 'tail' : '', | 203 | 'tail' : '', |
204 | 'make' : '', | 204 | 'make' : '', |
205 | 'model' : '', | 205 | 'model' : '', |
206 | 'sizeId' : '', | 206 | 'sizeId' : '', |
207 | 'marginId' : $scope.data.masterMargin, | 207 | 'marginId' : $scope.data.masterMargin, |
208 | 'avgasMarginId' : $scope.data.avgasMargin | 208 | 'avgasMarginId' : $scope.data.avgasMargin |
209 | } ]; | 209 | } ]; |
210 | 210 | ||
211 | $(sel).trigger('next.m.' + step); | 211 | $(sel).trigger('next.m.' + step); |
212 | getData(); | 212 | getData(); |
213 | } | 213 | } |
214 | $scope.showLoader = false; | 214 | $scope.showLoader = false; |
215 | } | 215 | } |
216 | 216 | ||
217 | $scope.addNew = function() { | 217 | $scope.addNew = function() { |
218 | $scope.showLoader = true; | 218 | $scope.showLoader = true; |
219 | $scope.aircraftDetails.push({ | 219 | $scope.aircraftDetails.push({ |
220 | 'tail' : '', | 220 | 'tail' : '', |
221 | 'make' : '', | 221 | 'make' : '', |
222 | 'model' : '', | 222 | 'model' : '', |
223 | 'sizeId' : '', | 223 | 'sizeId' : '', |
224 | 'marginId' : $scope.data.masterMargin, | 224 | 'marginId' : $scope.data.masterMargin, |
225 | 'avgasMarginId' : $scope.data.avgasMargin | 225 | 'avgasMarginId' : $scope.data.avgasMargin |
226 | }); | 226 | }); |
227 | $scope.showLoader = false; | 227 | $scope.showLoader = false; |
228 | }; | 228 | }; |
229 | 229 | ||
230 | $scope.aircraftIdx = ''; | 230 | $scope.aircraftIdx = ''; |
231 | $scope.checkTail = function(tail, idx){ | 231 | $scope.checkTail = function(tail, idx){ |
232 | var data = "tail=" + tail; | 232 | var data = "tail=" + tail; |
233 | $scope.aircraftIdx = idx; | 233 | $scope.aircraftIdx = idx; |
234 | CustomersService.checkTailRegistration(data).then(function(result) { | 234 | CustomersService.checkTailRegistration(data).then(function(result) { |
235 | if(result.error) { | 235 | if(result.error) { |
236 | $scope.aircraftMessage = result.error; | 236 | $scope.aircraftMessage = result.error; |
237 | $scope.openAddAirCraftError(); | 237 | $scope.openAddAirCraftError(); |
238 | } else if(result.warning) { | 238 | } else if(result.warning) { |
239 | $scope.aircraftMessage = result.warning; | 239 | $scope.aircraftMessage = result.warning; |
240 | $scope.openAddAirCraftWarning(); | 240 | $scope.openAddAirCraftWarning(); |
241 | } | 241 | } |
242 | }) | 242 | }) |
243 | } | 243 | } |
244 | 244 | ||
245 | $scope.openAddAirCraftError = function() { | 245 | $scope.openAddAirCraftError = function() { |
246 | $('#addAirCraftError').css('display', 'block'); | 246 | $('#addAirCraftError').css('display', 'block'); |
247 | } | 247 | } |
248 | 248 | ||
249 | $scope.openAddAirCraftWarning = function() { | 249 | $scope.openAddAirCraftWarning = function() { |
250 | $('#addAirCraftWarning').css('display', 'block'); | 250 | $('#addAirCraftWarning').css('display', 'block'); |
251 | } | 251 | } |
252 | $scope.acceptAirCraftError = function() { | 252 | $scope.acceptAirCraftError = function() { |
253 | $('#addAirCraftWarning').css('display', 'none'); | 253 | $('#addAirCraftWarning').css('display', 'none'); |
254 | } | 254 | } |
255 | 255 | ||
256 | $scope.cancelAirCraftError = function() { | 256 | $scope.cancelAirCraftError = function() { |
257 | $scope.aircraftDetails[$scope.aircraftIdx].tail = ''; | 257 | $scope.aircraftDetails[$scope.aircraftIdx].tail = ''; |
258 | $('#addAirCraftWarning').css('display', 'none'); | 258 | $('#addAirCraftWarning').css('display', 'none'); |
259 | $('#addAirCraftError').css('display', 'none'); | 259 | $('#addAirCraftError').css('display', 'none'); |
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||
263 | /*$scope.getModal = function(makeId, index) { | 263 | /*$scope.getModal = function(makeId, index) { |
264 | $scope.showLoader = true; | 264 | $scope.showLoader = true; |
265 | CustomersService.getModal($scope.aircraft.make).then(function(result) { | 265 | CustomersService.getModal($scope.aircraft.make).then(function(result) { |
266 | $scope.showLoader = false; | 266 | $scope.showLoader = false; |
267 | $scope.aircraftDetails[index].aircraftModalList = result; | 267 | $scope.aircraftDetails[index].aircraftModalList = result; |
268 | }) | 268 | }) |
269 | }*/ | 269 | }*/ |
270 | $scope.getModal = function(makeId, index) { | 270 | $scope.getModal = function(makeId, index) { |
271 | $scope.showLoader = true; | 271 | $scope.showLoader = true; |
272 | $scope.aircraft.make = makeId; | 272 | $scope.aircraft.make = makeId; |
273 | CustomersService.getModal($scope.aircraft.make).then(function(result) { | 273 | CustomersService.getModal($scope.aircraft.make).then(function(result) { |
274 | $scope.showLoader = false; | 274 | $scope.showLoader = false; |
275 | $scope.aircraftDetails[index].aircraftModalList = result; | 275 | $scope.aircraftDetails[index].aircraftModalList = result; |
276 | }) | 276 | }) |
277 | } | 277 | } |
278 | 278 | ||
279 | 279 | ||
280 | $scope.selectedOption = ''; | 280 | $scope.selectedOption = ''; |
281 | $scope.getSize = function(model, index) { | 281 | $scope.getSize = function(model, index) { |
282 | $scope.showLoader = true; | 282 | $scope.showLoader = true; |
283 | $scope.aircraft.model = model; | 283 | $scope.aircraft.model = model; |
284 | CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { | 284 | CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { |
285 | $scope.showLoader = false; | 285 | $scope.showLoader = false; |
286 | $scope.aircraftDetails[index].aircraftSizeList = result; | 286 | $scope.aircraftDetails[index].aircraftSizeList = result; |
287 | $scope.getFuelType($scope.aircraftDetails[index].aircraftSizeList[0].aircraftSize.id,index); | 287 | $scope.getFuelType($scope.aircraftDetails[index].aircraftSizeList[0].aircraftSize.id,index); |
288 | 288 | ||
289 | }) | 289 | }) |
290 | } | 290 | } |
291 | 291 | ||
292 | /*$scope.getSize = function(model, index) { | 292 | /*$scope.getSize = function(model, index) { |
293 | $scope.showLoader = true; | 293 | $scope.showLoader = true; |
294 | CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { | 294 | CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { |
295 | $scope.showLoader = false; | 295 | $scope.showLoader = false; |
296 | $scope.aircraftDetails[index].aircraftSizeList = result; | 296 | $scope.aircraftDetails[index].aircraftSizeList = result; |
297 | }) | 297 | }) |
298 | }*/ | 298 | }*/ |
299 | 299 | ||
300 | $scope.getFuelType = function(size, index) { | 300 | $scope.getFuelType = function(size, index) { |
301 | $scope.showLoader = true; | 301 | $scope.showLoader = true; |
302 | var data = "model="+$scope.aircraft.model+"&make="+$scope.aircraft.make+"&sizeId="+size; | 302 | var data = "model="+$scope.aircraft.model+"&make="+$scope.aircraft.make+"&sizeId="+size; |
303 | ViewCompanyService.checkFuelType(data).then(function(result){ | 303 | ViewCompanyService.checkFuelType(data).then(function(result){ |
304 | $scope.showLoader = false; | 304 | $scope.showLoader = false; |
305 | if (result.type == "JetA") { | 305 | if (result.type == "JetA") { |
306 | $scope.jetShow[index] = false; | 306 | $scope.jetShow[index] = false; |
307 | $scope.marginShow[index] = true; | 307 | $scope.marginShow[index] = true; |
308 | } else if (result.type == "Avgas") { | 308 | } else if (result.type == "Avgas") { |
309 | $scope.jetShow[index] = true; | 309 | $scope.jetShow[index] = true; |
310 | $scope.marginShow[index] = false; | 310 | $scope.marginShow[index] = false; |
311 | }else { | 311 | }else { |
312 | $scope.jetShow[index] = true; | 312 | $scope.jetShow[index] = true; |
313 | $scope.marginShow[index] = true; | 313 | $scope.marginShow[index] = true; |
314 | } | 314 | } |
315 | }) | 315 | }) |
316 | } | 316 | } |
317 | 317 | ||
318 | $scope.aircraftListData = {}; | 318 | $scope.aircraftListData = {}; |
319 | $scope.addData = []; | 319 | $scope.addData = []; |
320 | $scope.tailArray = []; | 320 | $scope.tailArray = []; |
321 | function check(array){ | 321 | function check(array){ |
322 | return (new Set(array)).size !== array.length; | 322 | return (new Set(array)).size !== array.length; |
323 | } | 323 | } |
324 | $scope.saveCompanyData = function() { | 324 | $scope.saveCompanyData = function() { |
325 | // console.log("company data --",$scope.data) | 325 | // console.log("company data --",$scope.data) |
326 | CustomersService.addCompany($scope.data).then(function(result) { | 326 | CustomersService.addCompany($scope.data).then(function(result) { |
327 | $scope.tailArray = []; | 327 | $scope.tailArray = []; |
328 | $scope.addData =[]; | 328 | $scope.addData =[]; |
329 | $scope.accountId = result; | 329 | $scope.accountId = result; |
330 | $scope.aircraft.accountId = $scope.accountId; | 330 | $scope.aircraft.accountId = $scope.accountId; |
331 | 331 | ||
332 | for (var i = 0; i < $scope.aircraftDetails.length; i++) { | 332 | for (var i = 0; i < $scope.aircraftDetails.length; i++) { |
333 | $scope.addData.push({ | 333 | $scope.addData.push({ |
334 | 'tail' : $scope.aircraftDetails[i].tail, | 334 | 'tail' : $scope.aircraftDetails[i].tail, |
335 | 'make' : $scope.aircraftDetails[i].make, | 335 | 'make' : $scope.aircraftDetails[i].make, |
336 | 'model' : $scope.aircraftDetails[i].model, | 336 | 'model' : $scope.aircraftDetails[i].model, |
337 | 'sizeId' : $scope.aircraftDetails[i].sizeId, | 337 | 'sizeId' : $scope.aircraftDetails[i].sizeId, |
338 | 'marginId' : $scope.aircraftDetails[i].marginId, | 338 | 'marginId' : $scope.aircraftDetails[i].marginId, |
339 | 'avgasMarginId' : $scope.aircraftDetails[i].avgasMarginId | 339 | 'avgasMarginId' : $scope.aircraftDetails[i].avgasMarginId |
340 | }); | 340 | }); |
341 | $scope.tailArray.push($scope.aircraftDetails[i].tail); | 341 | $scope.tailArray.push($scope.aircraftDetails[i].tail); |
342 | } | 342 | } |
343 | 343 | ||
344 | if (check($scope.tailArray)) { | 344 | if (check($scope.tailArray)) { |
345 | toastr.error('Duplicate Tail Added.', { | 345 | toastr.error('Duplicate Tail Added.', { |
346 | closeButton: true | 346 | closeButton: true |
347 | }) | 347 | }) |
348 | }else{ | 348 | }else{ |
349 | $scope.aircraftListData.aircraftList = $scope.addData; | 349 | $scope.aircraftListData.aircraftList = $scope.addData; |
350 | $scope.aircraftListData.accountId = $scope.aircraft.accountId; | 350 | $scope.aircraftListData.accountId = $scope.aircraft.accountId; |
351 | /*if ($scope.aircraftListData.aircraftList[0].tail == "" || $scope.aircraftListData.aircraftList[0].make == null || $scope.aircraftListData.aircraftList[0].model == null) { | 351 | /*if ($scope.aircraftListData.aircraftList[0].tail == "" || $scope.aircraftListData.aircraftList[0].make == null || $scope.aircraftListData.aircraftList[0].model == null) { |
352 | $scope.aircraftListData.aircraftList = []; | 352 | $scope.aircraftListData.aircraftList = []; |
353 | }*/ | 353 | }*/ |
354 | 354 | ||
355 | CustomersService.addAircraft($scope.aircraftListData).then(function(result) { | 355 | CustomersService.addAircraft($scope.aircraftListData).then(function(result) { |
356 | 356 | ||
357 | if (result != null && result.success) { | 357 | if (result != null && result.success) { |
358 | 358 | ||
359 | toastr.success('' + result.success + '', { | 359 | toastr.success('' + result.success + '', { |
360 | closeButton : true | 360 | closeButton : true |
361 | }) | 361 | }) |
362 | $('#demo-modal-3').css('display', 'none'); | 362 | $('#demo-modal-3').css('display', 'none'); |
363 | $('.modal-backdrop').css('display', 'none'); | 363 | $('.modal-backdrop').css('display', 'none'); |
364 | getAllCompanies(); | 364 | getAllCompanies(); |
365 | location.reload(); | 365 | location.reload(); |
366 | } else { | 366 | } else { |
367 | toastr.error('' + result.statusText + '', { | 367 | toastr.error('' + result.statusText + '', { |
368 | closeButton : true | 368 | closeButton : true |
369 | }) | 369 | }) |
370 | } | 370 | } |
371 | }); | 371 | }); |
372 | } | 372 | } |
373 | }) | 373 | }) |
374 | } | 374 | } |
375 | 375 | ||
376 | /*add a fuel order*/ | 376 | /*add a fuel order*/ |
377 | $scope.getOrders = function() { | 377 | $scope.getOrders = function() { |
378 | fuelOrdersService.getOrders().then(function(result) { | 378 | fuelOrdersService.getOrders().then(function(result) { |
379 | //console.log("==get orders===",result) | 379 | //console.log("==get orders===",result) |
380 | $scope.orderdata = result; | 380 | $scope.orderdata = result; |
381 | for (var i = 0; i < $scope.orderdata.length; i++) { | 381 | for (var i = 0; i < $scope.orderdata.length; i++) { |
382 | $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); | 382 | $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); |
383 | 383 | ||
384 | // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear() | 384 | // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear() |
385 | var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear() | 385 | var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear() |
386 | // str = str.slice(4,16) | 386 | // str = str.slice(4,16) |
387 | $scope.orderdata[i].upliftDateString = str | 387 | $scope.orderdata[i].upliftDateString = str |
388 | // console.log(str); | 388 | // console.log(str); |
389 | 389 | ||
390 | } | 390 | } |
391 | 391 | ||
392 | $scope.displayFuelOrderList = new NgTableParams({ | 392 | $scope.displayFuelOrderList = new NgTableParams({ |
393 | page : 1, | 393 | page : 1, |
394 | count : 10, | 394 | count : 10, |
395 | }, { | 395 | }, { |
396 | data : $scope.orderdata | 396 | data : $scope.orderdata |
397 | }); | 397 | }); |
398 | $(document).ready(function() { | 398 | $(document).ready(function() { |
399 | var myselect = document.getElementsByClassName('colorfulSelectbox'); | 399 | var myselect = document.getElementsByClassName('colorfulSelectbox'); |
400 | 400 | ||
401 | for (var i = 0; i < myselect.length; i++) { | 401 | for (var i = 0; i < myselect.length; i++) { |
402 | var colourIndex = $(myselect[i]).prop('selectedIndex'); | 402 | var colourIndex = $(myselect[i]).prop('selectedIndex'); |
403 | colourIndex = colourIndex + 1; | 403 | colourIndex = colourIndex + 1; |
404 | // console.log(colourIndex); | 404 | // console.log(colourIndex); |
405 | var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color'); | 405 | var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color'); |
406 | $(myselect[i]).css('background-color', getColor); | 406 | $(myselect[i]).css('background-color', getColor); |
407 | // console.log('colour', getColor); | 407 | // console.log('colour', getColor); |
408 | myselect[i].blur(); | 408 | myselect[i].blur(); |
409 | } | 409 | } |
410 | 410 | ||
411 | }) | 411 | }) |
412 | 412 | ||
413 | }) | 413 | }) |
414 | } | 414 | } |
415 | 415 | ||
416 | $scope.getOrders(); | 416 | $scope.getOrders(); |
417 | $scope.tiervalue=function(){ | 417 | $scope.tiervalue=function(){ |
418 | $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; | 418 | $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; |
419 | } | 419 | } |
420 | 420 | ||
421 | $scope.setCost = function(cost){ | 421 | $scope.setCost = function(cost){ |
422 | if(cost != null) { | 422 | if(cost != null) { |
423 | var obj =JSON.parse(cost); | 423 | var obj =JSON.parse(cost); |
424 | $scope.order.fboCost = obj.cost; | 424 | $scope.order.fboCost = obj.cost; |
425 | } | 425 | } |
426 | } | 426 | } |
427 | 427 | ||
428 | $scope.cancelOrder = function() { | 428 | $scope.cancelOrder = function() { |
429 | $scope.order = {}; | 429 | $scope.order = {}; |
430 | } | 430 | } |
431 | 431 | ||
432 | $scope.dispatchFuel = function(){ | 432 | $scope.dispatchFuel = function(){ |
433 | $scope.showLoader = true; | 433 | $scope.showLoader = true; |
434 | $scope.fuelData = {}; | 434 | $scope.fuelData = {}; |
435 | $scope.fuelData.companyId = $scope.selectedCompanyId; | 435 | $scope.fuelData.companyId = $scope.selectedCompanyId; |
436 | $scope.fuelData.companyName =$scope.order.defaultCompanyName; | 436 | $scope.fuelData.companyName =$scope.order.defaultCompanyName; |
437 | var aircraftObj =JSON.parse($scope.order.aircraftName); | 437 | var aircraftObj =JSON.parse($scope.order.aircraftName); |
438 | $scope.fuelData.aircraftName = aircraftObj.tail; | 438 | $scope.fuelData.aircraftName = aircraftObj.tail; |
439 | $scope.fuelData.make = aircraftObj.make; | 439 | $scope.fuelData.make = aircraftObj.make; |
440 | $scope.fuelData.model = aircraftObj.model; | 440 | $scope.fuelData.model = aircraftObj.model; |
441 | $scope.fuelData.fuelOn = $scope.order.fuelOn; | 441 | $scope.fuelData.fuelOn = $scope.order.fuelOn; |
442 | $scope.fuelData.invoiced = $scope.order.invoiced; | 442 | $scope.fuelData.invoiced = $scope.order.invoiced; |
443 | $scope.fuelData.volume = $scope.order.volume; | 443 | $scope.fuelData.volume = $scope.order.volume; |
444 | // $scope.fuelData.source = $scope.order.source; | 444 | // $scope.fuelData.source = $scope.order.source; |
445 | 445 | ||
446 | $scope.fuelData.total = $scope.order.total; | 446 | $scope.fuelData.total = $scope.order.total; |
447 | //tier no use | 447 | //tier no use |
448 | $scope.fuelData.tierBreak = $scope.order.tierBreak; | 448 | $scope.fuelData.tierBreak = $scope.order.tierBreak; |
449 | 449 | ||
450 | var obj =JSON.parse($scope.order.priceQuote); | 450 | var obj =JSON.parse($scope.order.priceQuote); |
451 | $scope.fuelData.priceQuote = obj.papTotal; | 451 | $scope.fuelData.priceQuote = obj.papTotal; |
452 | $scope.fuelData.fboCost = obj.cost; | 452 | $scope.fuelData.fboCost = obj.cost; |
453 | $scope.fuelData.productName = obj.productName; | 453 | $scope.fuelData.productName = obj.productName; |
454 | 454 | ||
455 | $scope.fuelData.etaTime = $scope.order.etaTime; | 455 | $scope.fuelData.etaTime = $scope.order.etaTime; |
456 | $scope.fuelData.etdTime = $scope.order.etdTime; | 456 | $scope.fuelData.etdTime = $scope.order.etdTime; |
457 | $scope.fuelData.certificateType = $scope.order.certificateType; | 457 | $scope.fuelData.certificateType = $scope.order.certificateType; |
458 | var currentDate = new Date(); | 458 | var currentDate = new Date(); |
459 | var hours = currentDate.getHours(); | 459 | var hours = currentDate.getHours(); |
460 | var min = currentDate.getMinutes(); | 460 | var min = currentDate.getMinutes(); |
461 | var sec = currentDate.getSeconds(); | 461 | var sec = currentDate.getSeconds(); |
462 | if ($scope.order.upliftDate != '') { | 462 | if ($scope.order.upliftDate != '') { |
463 | $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; | 463 | $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; |
464 | $scope.order.upliftDate = new Date($scope.order.upliftDate); | 464 | $scope.order.upliftDate = new Date($scope.order.upliftDate); |
465 | $scope.fuelData.upliftDate = $scope.order.upliftDate.getTime(); | 465 | $scope.fuelData.upliftDate = $scope.order.upliftDate.getTime(); |
466 | } | 466 | } |
467 | 467 | ||
468 | 468 | ||
469 | if ($scope.order.departingDate != '') { | 469 | if ($scope.order.departingDate != '') { |
470 | $scope.order.departingDate = $scope.order.departingDate + ' ' + hours + ':' + min + ':' + sec; | 470 | $scope.order.departingDate = $scope.order.departingDate + ' ' + hours + ':' + min + ':' + sec; |
471 | $scope.order.departingDate = new Date($scope.order.departingDate); | 471 | $scope.order.departingDate = new Date($scope.order.departingDate); |
472 | $scope.fuelData.departingDate = $scope.order.departingDate.getTime(); | 472 | $scope.fuelData.departingDate = $scope.order.departingDate.getTime(); |
473 | } | 473 | } |
474 | 474 | ||
475 | if($scope.order.status === null || $scope.order.status === undefined){ | 475 | if($scope.order.status === null || $scope.order.status === undefined){ |
476 | 476 | ||
477 | $scope.fuelData.status = "pending"; //default status | 477 | $scope.fuelData.status = "pending"; //default status |
478 | 478 | ||
479 | }else { | 479 | }else { |
480 | 480 | ||
481 | $scope.fuelData.status = $scope.order.status; | 481 | $scope.fuelData.status = $scope.order.status; |
482 | } | 482 | } |
483 | 483 | ||
484 | if($scope.baseTenant && $scope.contractFuelVendor ){ | 484 | if($scope.baseTenant && $scope.contractFuelVendor ){ |
485 | $scope.fuelData.source = "Tenant/CAA" ; | 485 | $scope.fuelData.source = "Tenant/CAA" ; |
486 | }else if($scope.baseTenant) | 486 | }else if($scope.baseTenant) |
487 | { | 487 | { |
488 | $scope.fuelData.source = "Tenant/Base Customer"; | 488 | $scope.fuelData.source = "Tenant/Base Customer"; |
489 | }else if($scope.contractFuelVendor){ | 489 | }else if($scope.contractFuelVendor){ |
490 | $scope.fuelData.source = "CAA Member"; | 490 | $scope.fuelData.source = "CAA Member"; |
491 | } | 491 | } |
492 | 492 | ||
493 | $scope.dispatchOrder.fuelOrderList.push($scope.fuelData); | 493 | $scope.dispatchOrder.fuelOrderList.push($scope.fuelData); |
494 | //console.log("=====$scope.fueldata======",$scope.fuelData) | 494 | //console.log("=====$scope.fueldata======",$scope.fuelData) |
495 | fuelOrdersService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { | 495 | fuelOrdersService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { |
496 | $scope.showLoader = false; | 496 | $scope.showLoader = false; |
497 | $scope.order = {}; | 497 | $scope.order = {}; |
498 | $scope.dispatchOrder.fuelOrderList = []; | 498 | $scope.dispatchOrder.fuelOrderList = []; |
499 | $('#demo-modal-4').css('display', ''); | 499 | $('#demo-modal-4').css('display', ''); |
500 | $scope.getOrders(); | 500 | $scope.getOrders(); |
501 | toastr.success('Fuel Order Dispatched Successfully', { | 501 | toastr.success('Fuel Order Dispatched Successfully', { |
502 | closeButton: true | 502 | closeButton: true |
503 | }) | 503 | }) |
504 | }) | 504 | }) |
505 | } | 505 | } |
506 | 506 | ||
507 | $scope.addTotal = function(value, valueOf) { | 507 | $scope.addTotal = function(value, valueOf) { |
508 | if (value != undefined && valueOf != undefined) { | 508 | if (value != undefined && valueOf != undefined) { |
509 | value = JSON.parse(value) | 509 | value = JSON.parse(value) |
510 | $scope.order.total = value.cost * valueOf; | 510 | $scope.order.total = Math.abs(value.papTotal) * valueOf; |
511 | } | 511 | } |
512 | } | 512 | } |
513 | 513 | ||
514 | $scope.getAircraft = function(company) { | 514 | $scope.getAircraft = function(company) { |
515 | $scope.selectedCompanyName = company; | 515 | $scope.selectedCompanyName = company; |
516 | //$scope.showLoader = true; | 516 | //$scope.showLoader = true; |
517 | // console.log("id",company) | 517 | // console.log("id",company) |
518 | for (var i = 0; i < $scope.companyList.length; i++) { | 518 | for (var i = 0; i < $scope.companyList.length; i++) { |
519 | if ($scope.companyList[i].companyName == company) { | 519 | if ($scope.companyList[i].companyName == company) { |
520 | if ($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null) { | 520 | if ($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null) { |
521 | fuelOrdersService.getFuelCost($scope.companyList[i].id).then(function(margins) { | 521 | fuelOrdersService.getFuelCost($scope.companyList[i].id).then(function(margins) { |
522 | $scope.marginList = margins; | 522 | $scope.marginList = margins; |
523 | //console.log('$scope.marginList', $scope.marginList); | 523 | //console.log('$scope.marginList', $scope.marginList); |
524 | }) | 524 | }) |
525 | } else if ($scope.companyList[i].margin != null || $scope.companyList[i].marginAVGAS == null) { | 525 | } else if ($scope.companyList[i].margin != null || $scope.companyList[i].marginAVGAS == null) { |
526 | fuelOrdersService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) { | 526 | fuelOrdersService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) { |
527 | $scope.marginList = margins; | 527 | $scope.marginList = margins; |
528 | }) | 528 | }) |
529 | } else if ($scope.companyList[i].margin == null || $scope.companyList[i].marginAVGAS != null) { | 529 | } else if ($scope.companyList[i].margin == null || $scope.companyList[i].marginAVGAS != null) { |
530 | fuelOrdersService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) { | 530 | fuelOrdersService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) { |
531 | $scope.marginList = margins; | 531 | $scope.marginList = margins; |
532 | }) | 532 | }) |
533 | } | 533 | } |
534 | $scope.selectedCompanyId = $scope.companyList[i].id; | 534 | $scope.selectedCompanyId = $scope.companyList[i].id; |
535 | $scope.marginId = $scope.companyList[i].margin.id; | 535 | $scope.marginId = $scope.companyList[i].margin.id; |
536 | if ($scope.selectedCompanyId != '') { | 536 | if ($scope.selectedCompanyId != '') { |
537 | fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { | 537 | fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { |
538 | $scope.aircraftList = aircraft; | 538 | $scope.aircraftList = aircraft; |
539 | //console.log("===tail search====",aircraft); | 539 | //console.log("===tail search====",aircraft); |
540 | }) | 540 | }) |
541 | } | 541 | } |
542 | if ($scope.marginId != '') { | 542 | if ($scope.marginId != '') { |
543 | fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) { | 543 | fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) { |
544 | $scope.tierList = tiers; | 544 | $scope.tierList = tiers; |
545 | // $scope.showLoader = false; | 545 | // $scope.showLoader = false; |
546 | }) | 546 | }) |
547 | } else { | 547 | } else { |
548 | // $scope.showLoader = false; | 548 | // $scope.showLoader = false; |
549 | } | 549 | } |
550 | } | 550 | } |
551 | } | 551 | } |
552 | 552 | ||
553 | } | 553 | } |
554 | 554 | ||
555 | $scope.sourceList = [ { | 555 | $scope.sourceList = [ { |
556 | source : "Direct Jet-A" | 556 | source : "Direct Jet-A" |
557 | }, { | 557 | }, { |
558 | source : "Direct AVGAS 100LL" | 558 | source : "Direct AVGAS 100LL" |
559 | } ]; | 559 | } ]; |
560 | $scope.cancelData = function() { | 560 | $scope.cancelData = function() { |
561 | $scope.order = {}; | 561 | $scope.order = {}; |
562 | $('#demo-modal-4').css('display', ''); | 562 | $('#demo-modal-4').css('display', ''); |
563 | } | 563 | } |
564 | 564 | ||
565 | $scope.setFuel = function(companyName,baseTenant,contractFuelVendor,fuelerlinxCustomer,certificateType) { | 565 | $scope.setFuel = function(companyName,baseTenant,contractFuelVendor,fuelerlinxCustomer,certificateType) { |
566 | $('#demo-modal-4').css('display', 'block'); | 566 | $('#demo-modal-4').css('display', 'block'); |
567 | $scope.order.defaultCompanyName = companyName; | 567 | $scope.order.defaultCompanyName = companyName; |
568 | $scope.order.certificateType = certificateType; | 568 | $scope.order.certificateType = certificateType; |
569 | $scope.baseTenant = baseTenant; | 569 | $scope.baseTenant = baseTenant; |
570 | $scope.contractFuelVendor = contractFuelVendor; | 570 | $scope.contractFuelVendor = contractFuelVendor; |
571 | $scope.fuelerlinxCustomer = fuelerlinxCustomer; | 571 | $scope.fuelerlinxCustomer = fuelerlinxCustomer; |
572 | //console.log("===values of checkbox===",baseTenant,contractFuelVendor,fuelerlinxCustomer) | 572 | //console.log("===values of checkbox===",baseTenant,contractFuelVendor,fuelerlinxCustomer) |
573 | $scope.getAircraft(companyName); | 573 | $scope.getAircraft(companyName); |
574 | // event.stopPropagation(); | 574 | // event.stopPropagation(); |
575 | // $state.go('app.updateFuelManager'); | 575 | // $state.go('app.updateFuelManager'); |
576 | } | 576 | } |
577 | 577 | ||
578 | /* ng table */ | 578 | /* ng table */ |
579 | 579 | ||
580 | $scope.exportCompany = function() { | 580 | $scope.exportCompany = function() { |
581 | $scope.showLoader = true; | 581 | $scope.showLoader = true; |
582 | var fileName = "companies.csv"; | 582 | var fileName = "companies.csv"; |
583 | var a = document.createElement("a"); | 583 | var a = document.createElement("a"); |
584 | document.body.appendChild(a); | 584 | document.body.appendChild(a); |
585 | CustomersService.exportCompany().then(function(result) { | 585 | CustomersService.exportCompany().then(function(result) { |
586 | var file = new Blob([ result ], { | 586 | var file = new Blob([ result ], { |
587 | type : 'application/csv' | 587 | type : 'application/csv' |
588 | }); | 588 | }); |
589 | var fileURL = URL.createObjectURL(file); | 589 | var fileURL = URL.createObjectURL(file); |
590 | a.href = fileURL; | 590 | a.href = fileURL; |
591 | a.download = fileName; | 591 | a.download = fileName; |
592 | a.click(); | 592 | a.click(); |
593 | $scope.showLoader = false; | 593 | $scope.showLoader = false; |
594 | }) | 594 | }) |
595 | } | 595 | } |
596 | getCompanyName(); | 596 | getCompanyName(); |
597 | function getCompanyName() { | 597 | function getCompanyName() { |
598 | CustomersService.getCompanyName().then(function(result) { | 598 | CustomersService.getCompanyName().then(function(result) { |
599 | $scope.compNameList = result; | 599 | $scope.compNameList = result; |
600 | //console.log("kd",result) | 600 | //console.log("kd",result) |
601 | }) | 601 | }) |
602 | } | 602 | } |
603 | 603 | ||
604 | // old api not use | 604 | // old api not use |
605 | /*$scope.checkJetWithTail = function(tail, index) { | 605 | /*$scope.checkJetWithTail = function(tail, index) { |
606 | ViewCompanyService.checkJetType(tail).then(function(result) { | 606 | ViewCompanyService.checkJetType(tail).then(function(result) { |
607 | if (result.jetA == "true") { | 607 | if (result.jetA == "true") { |
608 | $scope.jetShow[index] = false; | 608 | $scope.jetShow[index] = false; |
609 | $scope.marginShow[index] = true; | 609 | $scope.marginShow[index] = true; |
610 | } else { | 610 | } else { |
611 | $scope.jetShow[index] = true; | 611 | $scope.jetShow[index] = true; |
612 | $scope.marginShow[index] = false; | 612 | $scope.marginShow[index] = false; |
613 | } | 613 | } |
614 | }) | 614 | }) |
615 | }*/ | 615 | }*/ |
616 | 616 | ||
617 | 617 | ||
618 | $scope.etaTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, | 618 | $scope.etaTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, |
619 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, | 619 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, |
620 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, | 620 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, |
621 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, | 621 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, |
622 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, | 622 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, |
623 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; | 623 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; |
624 | 624 | ||
625 | $scope.etdTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, | 625 | $scope.etdTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, |
626 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, | 626 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, |
627 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, | 627 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, |
628 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, | 628 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, |
629 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, | 629 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, |
630 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; | 630 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; |
631 | 631 | ||
632 | } | 632 | } |
app/partials/enterFuelOrder/enterFuelOrder.controller.js
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | angular.module('acufuel') | 3 | angular.module('acufuel') |
4 | 4 | ||
5 | .controller('enterFuelOrderController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'enterFuelOrderService', enterFuelOrderController]); | 5 | .controller('enterFuelOrderController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'enterFuelOrderService', enterFuelOrderController]); |
6 | 6 | ||
7 | function enterFuelOrderController($scope, $rootScope, $uibModal, $filter, $http, enterFuelOrderService) { | 7 | function enterFuelOrderController($scope, $rootScope, $uibModal, $filter, $http, enterFuelOrderService) { |
8 | $scope.showLoader = true; | 8 | $scope.showLoader = true; |
9 | 9 | ||
10 | $scope.companyList = {}; | 10 | $scope.companyList = {}; |
11 | 11 | ||
12 | enterFuelOrderService.getAllCompanies().then(function(result) { | 12 | enterFuelOrderService.getAllCompanies().then(function(result) { |
13 | $scope.showLoader = false; | 13 | $scope.showLoader = false; |
14 | $scope.companyList = result; | 14 | $scope.companyList = result; |
15 | //console.log("===company====",result) | 15 | //console.log("===company====",result) |
16 | }) | 16 | }) |
17 | 17 | ||
18 | $scope.order = {}; | 18 | $scope.order = {}; |
19 | $scope.dispatchOrder = {}; | 19 | $scope.dispatchOrder = {}; |
20 | $scope.dispatchOrder.fuelOrderList = []; | 20 | $scope.dispatchOrder.fuelOrderList = []; |
21 | $scope.order.upliftDate = ''; | 21 | $scope.order.upliftDate = ''; |
22 | //$scope.order.departingDate = ''; | 22 | //$scope.order.departingDate = ''; |
23 | $scope.selectedCompanyName = ''; | 23 | $scope.selectedCompanyName = ''; |
24 | $scope.selectedCompanyId = ''; | 24 | $scope.selectedCompanyId = ''; |
25 | $scope.marginId = ''; | 25 | $scope.marginId = ''; |
26 | $scope.selectedTier = ''; | 26 | $scope.selectedTier = ''; |
27 | 27 | ||
28 | $scope.getAircraft = function(company){ | 28 | $scope.getAircraft = function(company){ |
29 | $scope.selectedCompanyName = company; | 29 | $scope.selectedCompanyName = company; |
30 | 30 | ||
31 | 31 | ||
32 | $scope.showLoader = true; | 32 | $scope.showLoader = true; |
33 | for (var i = 0; i < $scope.companyList.length; i++) { | 33 | for (var i = 0; i < $scope.companyList.length; i++) { |
34 | if ($scope.companyList[i].companyName == company) { | 34 | if ($scope.companyList[i].companyName == company) { |
35 | $scope.order.certificateType = $scope.companyList[i].certificateType; | 35 | $scope.order.certificateType = $scope.companyList[i].certificateType; |
36 | $scope.baseTenant = $scope.companyList[i].baseTenant; | 36 | $scope.baseTenant = $scope.companyList[i].baseTenant; |
37 | $scope.contractFuelVendor = $scope.companyList[i].contractFuelVendor; | 37 | $scope.contractFuelVendor = $scope.companyList[i].contractFuelVendor; |
38 | $scope.fuelerlinxCustomer = $scope.companyList[i].fuelerlinxCustomer; | 38 | $scope.fuelerlinxCustomer = $scope.companyList[i].fuelerlinxCustomer; |
39 | 39 | ||
40 | if($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null){ | 40 | if($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null){ |
41 | enterFuelOrderService.getFuelCost($scope.companyList[i].id).then(function(margins) { | 41 | enterFuelOrderService.getFuelCost($scope.companyList[i].id).then(function(margins) { |
42 | $scope.marginList = margins; | 42 | $scope.marginList = margins; |
43 | }) | 43 | }) |
44 | } else if ($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS == null) { | 44 | } else if ($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS == null) { |
45 | enterFuelOrderService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) { | 45 | enterFuelOrderService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) { |
46 | $scope.marginList = margins; | 46 | $scope.marginList = margins; |
47 | }) | 47 | }) |
48 | } else if ($scope.companyList[i].margin == null && $scope.companyList[i].marginAVGAS != null) { | 48 | } else if ($scope.companyList[i].margin == null && $scope.companyList[i].marginAVGAS != null) { |
49 | enterFuelOrderService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) { | 49 | enterFuelOrderService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) { |
50 | $scope.marginList = margins; | 50 | $scope.marginList = margins; |
51 | }) | 51 | }) |
52 | } else if ($scope.companyList[i].margin == null && $scope.companyList[i].marginAVGAS == null) { | 52 | } else if ($scope.companyList[i].margin == null && $scope.companyList[i].marginAVGAS == null) { |
53 | enterFuelOrderService.getPapFuelPricing($scope.companyList[i].id).then(function(margins) { | 53 | enterFuelOrderService.getPapFuelPricing($scope.companyList[i].id).then(function(margins) { |
54 | $scope.marginList = margins; | 54 | $scope.marginList = margins; |
55 | }) | 55 | }) |
56 | } | 56 | } |
57 | $scope.selectedCompanyId = $scope.companyList[i].id; | 57 | $scope.selectedCompanyId = $scope.companyList[i].id; |
58 | 58 | ||
59 | if ($scope.selectedCompanyId != '') { | 59 | if ($scope.selectedCompanyId != '') { |
60 | enterFuelOrderService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { | 60 | enterFuelOrderService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { |
61 | $scope.aircraftList = aircraft; | 61 | $scope.aircraftList = aircraft; |
62 | }) | 62 | }) |
63 | } | 63 | } |
64 | if($scope.companyList[i].margin == null) { | 64 | if($scope.companyList[i].margin == null) { |
65 | $scope.tierList = []; | 65 | $scope.tierList = []; |
66 | $scope.tierList.push({ | 66 | $scope.tierList.push({ |
67 | 'minTierBreak': '0', 'maxTierBreak': 'โ' | 67 | 'minTierBreak': '0', 'maxTierBreak': 'โ' |
68 | }); | 68 | }); |
69 | $scope.showLoader = false; | 69 | $scope.showLoader = false; |
70 | } else { | 70 | } else { |
71 | $scope.marginId = $scope.companyList[i].margin.id; | 71 | $scope.marginId = $scope.companyList[i].margin.id; |
72 | if ($scope.marginId != '') { | 72 | if ($scope.marginId != '') { |
73 | enterFuelOrderService.getJetTiers($scope.marginId).then(function(tiers) { | 73 | enterFuelOrderService.getJetTiers($scope.marginId).then(function(tiers) { |
74 | $scope.tierList = tiers; | 74 | $scope.tierList = tiers; |
75 | $scope.showLoader = false; | 75 | $scope.showLoader = false; |
76 | $scope.selectedTier = $scope.tierList[0]; | 76 | $scope.selectedTier = $scope.tierList[0]; |
77 | }) | 77 | }) |
78 | }else{ | 78 | }else{ |
79 | $scope.showLoader = false; | 79 | $scope.showLoader = false; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | } | 85 | } |
86 | 86 | ||
87 | $scope.tiervalue=function(){ | 87 | $scope.tiervalue=function(){ |
88 | $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; | 88 | $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | 92 | ||
93 | 93 | ||
94 | $scope.cancelOrder = function() { | 94 | $scope.cancelOrder = function() { |
95 | $scope.order = {}; | 95 | $scope.order = {}; |
96 | } | 96 | } |
97 | 97 | ||
98 | 98 | ||
99 | $scope.setCost = function(cost){ | 99 | $scope.setCost = function(cost){ |
100 | if(cost != null) { | 100 | if(cost != null) { |
101 | var obj =JSON.parse(cost); | 101 | var obj =JSON.parse(cost); |
102 | $scope.order.fboCost = obj.cost; | 102 | $scope.order.fboCost = obj.cost; |
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | /*$scope.addTotal = function(value, valueOf){ | 106 | |
107 | if(valueOf == 'v'){ | ||
108 | $scope.order.total = value * $scope.order.invoiced | ||
109 | }else if(valueOf == 'i'){ | ||
110 | $scope.order.total = $scope.order.volume * value | ||
111 | } | ||
112 | } */ | ||
113 | $scope.addTotal = function(value, valueOf) { | 107 | $scope.addTotal = function(value, valueOf) { |
114 | if (value != undefined && valueOf != undefined) { | 108 | if (value != undefined && valueOf != undefined) { |
115 | value = JSON.parse(value) | 109 | value = JSON.parse(value) |
116 | $scope.order.total = value.cost * valueOf; | 110 | $scope.order.total = Math.abs(value.papTotal) * valueOf; |
117 | } | 111 | } |
118 | } | 112 | } |
119 | 113 | ||
120 | $scope.dispatchFuel = function(){ | 114 | $scope.dispatchFuel = function(){ |
121 | $scope.showLoader = true; | 115 | $scope.showLoader = true; |
122 | 116 | ||
123 | $scope.order.companyId = $scope.selectedCompanyId; | 117 | $scope.order.companyId = $scope.selectedCompanyId; |
124 | $scope.order.companyName = $scope.order.companyName; | 118 | $scope.order.companyName = $scope.order.companyName; |
125 | var aircraftObj =JSON.parse($scope.order.aircraftName); | 119 | var aircraftObj =JSON.parse($scope.order.aircraftName); |
126 | $scope.order.aircraftName = aircraftObj.tail; | 120 | $scope.order.aircraftName = aircraftObj.tail; |
127 | $scope.order.make = aircraftObj.make; | 121 | $scope.order.make = aircraftObj.make; |
128 | $scope.order.model = aircraftObj.model; | 122 | $scope.order.model = aircraftObj.model; |
129 | $scope.order.fuelOn = $scope.order.fuelOn; | 123 | $scope.order.fuelOn = $scope.order.fuelOn; |
130 | 124 | ||
131 | $scope.order.invoiced = $scope.order.invoiced; | 125 | $scope.order.invoiced = $scope.order.invoiced; |
132 | $scope.order.volume = $scope.order.volume; | 126 | $scope.order.volume = $scope.order.volume; |
133 | // $scope.order.source = $scope.order.source; | 127 | // $scope.order.source = $scope.order.source; |
134 | 128 | ||
135 | $scope.order.total = $scope.order.total; | 129 | $scope.order.total = $scope.order.total; |
136 | 130 | ||
137 | var obj =JSON.parse($scope.order.priceQuote); | 131 | var obj =JSON.parse($scope.order.priceQuote); |
138 | $scope.order.priceQuote = obj.papTotal; | 132 | $scope.order.priceQuote = obj.papTotal; |
139 | $scope.order.fboCost = obj.cost; | 133 | $scope.order.fboCost = obj.cost; |
140 | $scope.order.productName = obj.productName; | 134 | $scope.order.productName = obj.productName; |
141 | 135 | ||
142 | $scope.order.etaTime = $scope.order.etaTime; | 136 | $scope.order.etaTime = $scope.order.etaTime; |
143 | $scope.order.etdTime = $scope.order.etdTime; | 137 | $scope.order.etdTime = $scope.order.etdTime; |
144 | $scope.order.certificateType = $scope.order.certificateType; | 138 | $scope.order.certificateType = $scope.order.certificateType; |
145 | var currentDate = new Date(); | 139 | var currentDate = new Date(); |
146 | var hours = currentDate.getHours(); | 140 | var hours = currentDate.getHours(); |
147 | var min = currentDate.getMinutes(); | 141 | var min = currentDate.getMinutes(); |
148 | var sec = currentDate.getSeconds(); | 142 | var sec = currentDate.getSeconds(); |
149 | if ($scope.order.upliftDate != '') { | 143 | if ($scope.order.upliftDate != '') { |
150 | $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; | 144 | $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; |
151 | $scope.order.upliftDate = new Date($scope.order.upliftDate); | 145 | $scope.order.upliftDate = new Date($scope.order.upliftDate); |
152 | $scope.order.upliftDate = $scope.order.upliftDate.getTime(); | 146 | $scope.order.upliftDate = $scope.order.upliftDate.getTime(); |
153 | } | 147 | } |
154 | 148 | ||
155 | 149 | ||
156 | if ($scope.order.departingDate != '') { | 150 | if ($scope.order.departingDate != '') { |
157 | $scope.order.departingDate = $scope.order.departingDate + ' ' + hours + ':' + min + ':' + sec; | 151 | $scope.order.departingDate = $scope.order.departingDate + ' ' + hours + ':' + min + ':' + sec; |
158 | $scope.order.departingDate = new Date($scope.order.departingDate); | 152 | $scope.order.departingDate = new Date($scope.order.departingDate); |
159 | $scope.order.departingDate = $scope.order.departingDate.getTime(); | 153 | $scope.order.departingDate = $scope.order.departingDate.getTime(); |
160 | } | 154 | } |
161 | 155 | ||
162 | if($scope.order.status === null || $scope.order.status === undefined){ | 156 | if($scope.order.status === null || $scope.order.status === undefined){ |
163 | 157 | ||
164 | $scope.order.status = "pending"; //default status | 158 | $scope.order.status = "pending"; //default status |
165 | 159 | ||
166 | }else { | 160 | }else { |
167 | 161 | ||
168 | $scope.order.status = $scope.order.status; | 162 | $scope.order.status = $scope.order.status; |
169 | } | 163 | } |
170 | 164 | ||
171 | if($scope.baseTenant && $scope.contractFuelVendor ){ | 165 | if($scope.baseTenant && $scope.contractFuelVendor ){ |
172 | $scope.order.source = "Tenant/CAA" ; | 166 | $scope.order.source = "Tenant/CAA" ; |
173 | }else if($scope.baseTenant) | 167 | }else if($scope.baseTenant) |
174 | { | 168 | { |
175 | $scope.order.source = "Tenant/Base Customer"; | 169 | $scope.order.source = "Tenant/Base Customer"; |
176 | }else if($scope.contractFuelVendor){ | 170 | }else if($scope.contractFuelVendor){ |
177 | $scope.order.source = "CAA Member"; | 171 | $scope.order.source = "CAA Member"; |
178 | } | 172 | } |
179 | 173 | ||
180 | //console.log("===order====",$scope.order); | 174 | //console.log("===order====",$scope.order); |
181 | 175 | ||
182 | $scope.dispatchOrder.fuelOrderList.push($scope.order); | 176 | $scope.dispatchOrder.fuelOrderList.push($scope.order); |
183 | 177 | ||
184 | enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { | 178 | enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { |
185 | $scope.showLoader = false; | 179 | $scope.showLoader = false; |
186 | $scope.order = {}; | 180 | $scope.order = {}; |
187 | toastr.success('Fuel Order Created Successfully', { | 181 | toastr.success('Fuel Order Created Successfully', { |
188 | closeButton: true | 182 | closeButton: true |
189 | }) | 183 | }) |
190 | }) | 184 | }) |
191 | } | 185 | } |
192 | 186 | ||
193 | 187 | ||
194 | $scope.etaTimeList=[]; | 188 | $scope.etaTimeList=[]; |
195 | $scope.etdTimeList =[]; | 189 | $scope.etdTimeList =[]; |
196 | 190 | ||
197 | $scope.etaTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, | 191 | $scope.etaTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, |
198 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, | 192 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, |
199 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, | 193 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, |
200 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, | 194 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, |
201 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, | 195 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, |
202 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; | 196 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; |
203 | 197 | ||
204 | $scope.etdTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, | 198 | $scope.etdTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, |
205 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, | 199 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, |
206 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, | 200 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, |
207 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, | 201 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, |
208 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, | 202 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, |
209 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; | 203 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; |
210 | 204 | ||
211 | } | 205 | } |
app/partials/fuelOrders/fuelOrders.controller.js
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | angular.module('acufuel') | 3 | angular.module('acufuel') |
4 | 4 | ||
5 | .controller('fuelOrdersController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'NgTableParams','$stateParams','fuelOrdersService','CustomersService','ViewCompanyService', fuelOrdersController]); | 5 | .controller('fuelOrdersController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'NgTableParams','$stateParams','fuelOrdersService','CustomersService','ViewCompanyService', fuelOrdersController]); |
6 | 6 | ||
7 | function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgTableParams,$stateParams,fuelOrdersService,CustomersService,ViewCompanyService) { | 7 | function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgTableParams,$stateParams,fuelOrdersService,CustomersService,ViewCompanyService) { |
8 | 8 | ||
9 | $scope.showFuelOrderModal = false; | 9 | $scope.showFuelOrderModal = false; |
10 | $scope.optionSelected; | 10 | $scope.optionSelected; |
11 | $scope.orderdata = {}; | 11 | $scope.orderdata = {}; |
12 | $scope.showLoader = false; | 12 | $scope.showLoader = false; |
13 | $scope.jetShow = []; | 13 | $scope.jetShow = []; |
14 | $scope.marginShow = []; | 14 | $scope.marginShow = []; |
15 | 15 | ||
16 | $scope.jetShow[0] = true; | 16 | $scope.jetShow[0] = true; |
17 | $scope.marginShow[0] = true; | 17 | $scope.marginShow[0] = true; |
18 | 18 | ||
19 | $scope.data = {}; | 19 | $scope.data = {}; |
20 | $scope.order = {}; | 20 | $scope.order = {}; |
21 | $scope.dispatchOrder = {}; | 21 | $scope.dispatchOrder = {}; |
22 | $scope.dispatchOrder.fuelOrderList = []; | 22 | $scope.dispatchOrder.fuelOrderList = []; |
23 | $scope.defaultStatus = ''; | 23 | $scope.defaultStatus = ''; |
24 | $scope.statusFilterOptions = []; | 24 | $scope.statusFilterOptions = []; |
25 | $scope.statusFilterOptions.push({ | 25 | $scope.statusFilterOptions.push({ |
26 | 'id': '', 'title': 'Show All' | 26 | 'id': '', 'title': 'Show All' |
27 | },{ | 27 | },{ |
28 | 'id': 'pending', 'title': 'Pending' | 28 | 'id': 'pending', 'title': 'Pending' |
29 | },{ | 29 | },{ |
30 | 'id': 'invoiced', 'title': 'Invoiced' | 30 | 'id': 'invoiced', 'title': 'Invoiced' |
31 | },{ | 31 | },{ |
32 | 'id': 'paid', 'title': 'Paid' | 32 | 'id': 'paid', 'title': 'Paid' |
33 | },{ | 33 | },{ |
34 | 'id': 'cancelled', 'title': 'Cancelled' | 34 | 'id': 'cancelled', 'title': 'Cancelled' |
35 | },{ | 35 | },{ |
36 | 'id': 'archived', 'title': 'Archived' | 36 | 'id': 'archived', 'title': 'Archived' |
37 | } | 37 | } |
38 | 38 | ||
39 | ); | 39 | ); |
40 | 40 | ||
41 | if($stateParams.status =="paid"){ | 41 | if($stateParams.status =="paid"){ |
42 | $scope.defaultStatus = "paid"; | 42 | $scope.defaultStatus = "paid"; |
43 | } | 43 | } |
44 | 44 | ||
45 | getAllCompanies(); | 45 | getAllCompanies(); |
46 | 46 | ||
47 | function getAllCompanies(){ | 47 | function getAllCompanies(){ |
48 | fuelOrdersService.getAllCompanies().then(function(result) { | 48 | fuelOrdersService.getAllCompanies().then(function(result) { |
49 | $scope.companyList = result; | 49 | $scope.companyList = result; |
50 | for (var i = 0; i < $scope.companyList.length; i++) { | 50 | for (var i = 0; i < $scope.companyList.length; i++) { |
51 | if ($scope.companyList[i].companyContact != null) { | 51 | if ($scope.companyList[i].companyContact != null) { |
52 | if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) { | 52 | if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) { |
53 | $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber; | 53 | $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber; |
54 | } | 54 | } |
55 | } | 55 | } |
56 | if ($scope.companyList[i].primaryContact != null) { | 56 | if ($scope.companyList[i].primaryContact != null) { |
57 | if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) { | 57 | if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) { |
58 | $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName; | 58 | $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName; |
59 | } | 59 | } |
60 | } | 60 | } |
61 | if ($scope.companyList[i].margin != null) { | 61 | if ($scope.companyList[i].margin != null) { |
62 | if ($scope.companyList[i].margin.marginName != null) { | 62 | if ($scope.companyList[i].margin.marginName != null) { |
63 | $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; | 63 | $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; |
64 | } | 64 | } |
65 | } | 65 | } |
66 | } | 66 | } |
67 | $scope.displayCompanyList = new NgTableParams({ | 67 | $scope.displayCompanyList = new NgTableParams({ |
68 | page: 1, | 68 | page: 1, |
69 | count: 10, | 69 | count: 10, |
70 | }, { | 70 | }, { |
71 | data: $scope.companyList | 71 | data: $scope.companyList |
72 | }); | 72 | }); |
73 | $scope.showLoader = false; | 73 | $scope.showLoader = false; |
74 | }) | 74 | }) |
75 | } | 75 | } |
76 | 76 | ||
77 | 77 | ||
78 | $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')) | 78 | $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')) |
79 | $scope.reset2 = function(){ | 79 | $scope.reset2 = function(){ |
80 | $("input").val(""); | 80 | $("input").val(""); |
81 | $scope.removeMarginValidation(); | 81 | $scope.removeMarginValidation(); |
82 | } | 82 | } |
83 | 83 | ||
84 | function colourFunction() { | 84 | function colourFunction() { |
85 | var myselect = document.getElementById('colorfulSelectbox'), | 85 | var myselect = document.getElementById('colorfulSelectbox'), |
86 | colour = myselect.options[myselect.selectedIndex].className; | 86 | colour = myselect.options[myselect.selectedIndex].className; |
87 | myselect.style.background = colour; | 87 | myselect.style.background = colour; |
88 | myselect.blur(); | 88 | myselect.blur(); |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | /*setInterval(function(){ | 92 | /*setInterval(function(){ |
93 | colourFunction(); | 93 | colourFunction(); |
94 | }, 1)*/ | 94 | }, 1)*/ |
95 | 95 | ||
96 | 96 | ||
97 | $scope.attachmentFilterOptions = []; | 97 | $scope.attachmentFilterOptions = []; |
98 | $scope.attachmentFilterOptions.push({ | 98 | $scope.attachmentFilterOptions.push({ |
99 | 'id': '', 'title': 'Show All' | 99 | 'id': '', 'title': 'Show All' |
100 | },{ | 100 | },{ |
101 | 'id': '!null', 'title': 'Attachments' | 101 | 'id': '!null', 'title': 'Attachments' |
102 | },{ | 102 | },{ |
103 | 'id': 'null', 'title': 'No Attachments' | 103 | 'id': 'null', 'title': 'No Attachments' |
104 | } | 104 | } |
105 | ); | 105 | ); |
106 | 106 | ||
107 | // $(document).ready(function() { | 107 | // $(document).ready(function() { |
108 | // $scope.showLoader = true; | 108 | // $scope.showLoader = true; |
109 | // $('#example').DataTable(); | 109 | // $('#example').DataTable(); |
110 | // $scope.showLoader = false; | 110 | // $scope.showLoader = false; |
111 | // }); | 111 | // }); |
112 | 112 | ||
113 | $scope.getOrders = function() { | 113 | $scope.getOrders = function() { |
114 | fuelOrdersService.getOrders().then(function(result) { | 114 | fuelOrdersService.getOrders().then(function(result) { |
115 | $scope.orderdata = result; | 115 | $scope.orderdata = result; |
116 | for(var i=0 ; i < $scope.orderdata.length ; i++){ | 116 | for(var i=0 ; i < $scope.orderdata.length ; i++){ |
117 | $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); | 117 | $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); |
118 | $scope.orderdata[i].departingDateS = new Date($scope.orderdata[i].departingDate); | 118 | $scope.orderdata[i].departingDateS = new Date($scope.orderdata[i].departingDate); |
119 | 119 | ||
120 | var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear(); | 120 | var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear(); |
121 | var departingStr = "" + ($scope.orderdata[i].departingDateS.getMonth() + 1) + "/" + $scope.orderdata[i].departingDateS.getDate() + "/" + $scope.orderdata[i].departingDateS.getFullYear(); | 121 | var departingStr = "" + ($scope.orderdata[i].departingDateS.getMonth() + 1) + "/" + $scope.orderdata[i].departingDateS.getDate() + "/" + $scope.orderdata[i].departingDateS.getFullYear(); |
122 | $scope.orderdata[i].upliftDateString = str; | 122 | $scope.orderdata[i].upliftDateString = str; |
123 | $scope.orderdata[i].departingDateString = departingStr; | 123 | $scope.orderdata[i].departingDateString = departingStr; |
124 | //not working in input type Time | 124 | //not working in input type Time |
125 | /*if ($scope.orderdata[i].etaTime != null) { | 125 | /*if ($scope.orderdata[i].etaTime != null) { |
126 | var now = new Date(); | 126 | var now = new Date(); |
127 | 127 | ||
128 | var hr = $scope.orderdata[i].etaTime.slice(0, 2); | 128 | var hr = $scope.orderdata[i].etaTime.slice(0, 2); |
129 | var mm = $scope.orderdata[i].etaTime.slice(3, 5); | 129 | var mm = $scope.orderdata[i].etaTime.slice(3, 5); |
130 | now.setHours(hr); | 130 | now.setHours(hr); |
131 | now.setMinutes(mm); | 131 | now.setMinutes(mm); |
132 | $scope.orderdata[i].etaTime = now; | 132 | $scope.orderdata[i].etaTime = now; |
133 | console.log("===eta====", now, hr, mm); | 133 | console.log("===eta====", now, hr, mm); |
134 | }*/ | 134 | }*/ |
135 | 135 | ||
136 | } | 136 | } |
137 | 137 | ||
138 | $scope.displayFuelOrderList = new NgTableParams({ | 138 | $scope.displayFuelOrderList = new NgTableParams({ |
139 | page: 1, | 139 | page: 1, |
140 | count: 10, | 140 | count: 10, |
141 | }, { | 141 | }, { |
142 | data: $scope.orderdata | 142 | data: $scope.orderdata |
143 | }); | 143 | }); |
144 | $(document).ready(function(){ | 144 | $(document).ready(function(){ |
145 | function changeSelectboxBg(){ | 145 | function changeSelectboxBg(){ |
146 | setInterval(function(){ | 146 | setInterval(function(){ |
147 | if ($('.table select').is(':focus')) { | 147 | if ($('.table select').is(':focus')) { |
148 | 148 | ||
149 | }else{ | 149 | }else{ |
150 | var myselect = document.getElementsByClassName('colorfulSelectbox'); | 150 | var myselect = document.getElementsByClassName('colorfulSelectbox'); |
151 | 151 | ||
152 | for (var i = 0; i < myselect.length; i++) { | 152 | for (var i = 0; i < myselect.length; i++) { |
153 | var colourIndex = $(myselect[i]).prop('selectedIndex'); | 153 | var colourIndex = $(myselect[i]).prop('selectedIndex'); |
154 | colourIndex = colourIndex + 1; | 154 | colourIndex = colourIndex + 1; |
155 | var getColor = $('.colorfulSelectbox option:nth-child('+colourIndex+')').css('color'); | 155 | var getColor = $('.colorfulSelectbox option:nth-child('+colourIndex+')').css('color'); |
156 | $(myselect[i]).css('background-color', getColor); | 156 | $(myselect[i]).css('background-color', getColor); |
157 | myselect[i].blur(); | 157 | myselect[i].blur(); |
158 | } | 158 | } |
159 | } | 159 | } |
160 | }, 1000) | 160 | }, 1000) |
161 | } | 161 | } |
162 | changeSelectboxBg(); | 162 | changeSelectboxBg(); |
163 | 163 | ||
164 | /*$('.pagination , .recordCountSelect').click(function(){ | 164 | /*$('.pagination , .recordCountSelect').click(function(){ |
165 | changeSelectboxBg(); | 165 | changeSelectboxBg(); |
166 | }) | 166 | }) |
167 | $('.input-filter').keydown(function(){ | 167 | $('.input-filter').keydown(function(){ |
168 | console.log('function..........'); | 168 | console.log('function..........'); |
169 | changeSelectboxBg(); | 169 | changeSelectboxBg(); |
170 | })*/ | 170 | })*/ |
171 | }) | 171 | }) |
172 | }) | 172 | }) |
173 | } | 173 | } |
174 | 174 | ||
175 | $scope.getOrders(); | 175 | $scope.getOrders(); |
176 | $scope.optionSelected=''; | 176 | $scope.optionSelected=''; |
177 | $scope.onFWSelect = function() { | 177 | $scope.onFWSelect = function() { |
178 | if($scope.optionSelected == 'dt'){ | 178 | if($scope.optionSelected == 'dt'){ |
179 | $('#demo-modal-4').css('display', 'block'); | 179 | $('#demo-modal-4').css('display', 'block'); |
180 | $scope.optionSelected=''; | 180 | $scope.optionSelected=''; |
181 | 181 | ||
182 | } | 182 | } |
183 | if($scope.optionSelected == 'efo'){ | 183 | if($scope.optionSelected == 'efo'){ |
184 | $scope.showLoader = true; | 184 | $scope.showLoader = true; |
185 | var fileName = "orders.csv"; | 185 | var fileName = "orders.csv"; |
186 | var a = document.createElement("a"); | 186 | var a = document.createElement("a"); |
187 | document.body.appendChild(a); | 187 | document.body.appendChild(a); |
188 | fuelOrdersService.exportCompany().then(function(result) { | 188 | fuelOrdersService.exportCompany().then(function(result) { |
189 | var file = new Blob([result], {type: 'application/csv'}); | 189 | var file = new Blob([result], {type: 'application/csv'}); |
190 | var fileURL = URL.createObjectURL(file); | 190 | var fileURL = URL.createObjectURL(file); |
191 | a.href = fileURL; | 191 | a.href = fileURL; |
192 | a.download = fileName; | 192 | a.download = fileName; |
193 | a.click(); | 193 | a.click(); |
194 | $scope.showLoader = false; | 194 | $scope.showLoader = false; |
195 | $scope.optionSelected=''; | 195 | $scope.optionSelected=''; |
196 | }) | 196 | }) |
197 | } | 197 | } |
198 | } | 198 | } |
199 | $scope.attachmentrowid = "" | 199 | $scope.attachmentrowid = "" |
200 | 200 | ||
201 | 201 | ||
202 | $scope.attachment = function(id, value, url) { | 202 | $scope.attachment = function(id, value, url) { |
203 | $scope.attachmentrowid = id | 203 | $scope.attachmentrowid = id |
204 | if(value == 'uploadAttachment'){ | 204 | if(value == 'uploadAttachment'){ |
205 | $('#demo-modal-6').css('display', 'block'); | 205 | $('#demo-modal-6').css('display', 'block'); |
206 | }else if(value == 'viewAttachment'){ | 206 | }else if(value == 'viewAttachment'){ |
207 | var win = window.open(url, '_blank'); | 207 | var win = window.open(url, '_blank'); |
208 | win.focus(); | 208 | win.focus(); |
209 | }else if(value == 'deleteAttachment'){ | 209 | }else if(value == 'deleteAttachment'){ |
210 | $('#delete1').css('display', 'block'); | 210 | $('#delete1').css('display', 'block'); |
211 | } | 211 | } |
212 | } | 212 | } |
213 | 213 | ||
214 | $scope.cancelDeleteAttachment = function() { | 214 | $scope.cancelDeleteAttachment = function() { |
215 | $('#delete1').css('display', ''); | 215 | $('#delete1').css('display', ''); |
216 | } | 216 | } |
217 | 217 | ||
218 | $scope.deleteAttachment = function() { | 218 | $scope.deleteAttachment = function() { |
219 | $scope.showLoader = true; | 219 | $scope.showLoader = true; |
220 | fuelOrdersService.deleteAttachment($scope.attachmentrowid).then(function(result) { | 220 | fuelOrdersService.deleteAttachment($scope.attachmentrowid).then(function(result) { |
221 | 221 | ||
222 | if(result.success){ | 222 | if(result.success){ |
223 | toastr.success(''+result.success+'', { | 223 | toastr.success(''+result.success+'', { |
224 | closeButton: true | 224 | closeButton: true |
225 | }) | 225 | }) |
226 | } | 226 | } |
227 | }) | 227 | }) |
228 | $scope.showLoader = false; | 228 | $scope.showLoader = false; |
229 | $('#delete1').css('display', ''); | 229 | $('#delete1').css('display', ''); |
230 | } | 230 | } |
231 | 231 | ||
232 | $scope.saveUploadAttachment = function(attachmentData) { | 232 | $scope.saveUploadAttachment = function(attachmentData) { |
233 | $scope.showLoader = true; | 233 | $scope.showLoader = true; |
234 | $scope.data.media = attachmentData | 234 | $scope.data.media = attachmentData |
235 | $scope.data.id = $scope.attachmentrowid | 235 | $scope.data.id = $scope.attachmentrowid |
236 | fuelOrdersService.uploadAttachment($scope.data).then(function(result) { | 236 | fuelOrdersService.uploadAttachment($scope.data).then(function(result) { |
237 | if(result){ | 237 | if(result){ |
238 | toastr.success(''+"Upload Successful"+'', { | 238 | toastr.success(''+"Upload Successful"+'', { |
239 | closeButton: true | 239 | closeButton: true |
240 | }) | 240 | }) |
241 | } | 241 | } |
242 | 242 | ||
243 | }) | 243 | }) |
244 | $scope.showLoader = false; | 244 | $scope.showLoader = false; |
245 | $('#demo-modal-6').css('display', 'none'); | 245 | $('#demo-modal-6').css('display', 'none'); |
246 | } | 246 | } |
247 | 247 | ||
248 | $scope.cancelUploadAttachment = function() { | 248 | $scope.cancelUploadAttachment = function() { |
249 | $('#demo-modal-6').css('display', 'none'); | 249 | $('#demo-modal-6').css('display', 'none'); |
250 | } | 250 | } |
251 | 251 | ||
252 | $scope.editdata = {}; | 252 | $scope.editdata = {}; |
253 | 253 | ||
254 | 254 | ||
255 | $scope.editTableRow = function(rowData){ | 255 | $scope.editTableRow = function(rowData){ |
256 | //console.log('row data', rowData); | 256 | //console.log('row data', rowData); |
257 | $scope.editdata = rowData; | 257 | $scope.editdata = rowData; |
258 | $('#demo-modal-5').css('display', 'block'); | 258 | $('#demo-modal-5').css('display', 'block'); |
259 | } | 259 | } |
260 | 260 | ||
261 | $scope.updateTotal = function(value, valueOf){ | 261 | $scope.updateTotal = function(value, valueOf){ |
262 | if(valueOf == 'v'){ | 262 | if(valueOf == 'v'){ |
263 | $scope.editdata.total = value * $scope.editdata.invoiced | 263 | $scope.editdata.total = value * $scope.editdata.invoiced |
264 | }else if(valueOf == 'i'){ | 264 | }else if(valueOf == 'i'){ |
265 | $scope.editdata.total = $scope.editdata.requestedVolume * value | 265 | $scope.editdata.total = $scope.editdata.requestedVolume * value |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | $scope.setCost = function(cost){ | 269 | $scope.setCost = function(cost){ |
270 | if(cost != null) { | 270 | if(cost != null) { |
271 | var obj =JSON.parse(cost); | 271 | var obj =JSON.parse(cost); |
272 | $scope.order.fboCost = obj.cost; | 272 | $scope.order.fboCost = obj.cost; |
273 | } | 273 | } |
274 | 274 | ||
275 | } | 275 | } |
276 | 276 | ||
277 | $scope.addTotal = function(value, valueOf) { | 277 | $scope.addTotal = function(value, valueOf) { |
278 | if (value != undefined && valueOf != undefined) { | 278 | if (value != undefined && valueOf != undefined) { |
279 | value = JSON.parse(value) | 279 | value = JSON.parse(value) |
280 | $scope.order.total = value.cost * valueOf; | 280 | $scope.order.total = Math.abs(value.papTotal) * valueOf; |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | $scope.addFuelData = function() { | 284 | $scope.addFuelData = function() { |
285 | $scope.showLoader = true; | 285 | $scope.showLoader = true; |
286 | $scope.fuelData = {}; | 286 | $scope.fuelData = {}; |
287 | $scope.fuelData.companyId = $scope.selectedCompanyId; | 287 | $scope.fuelData.companyId = $scope.selectedCompanyId; |
288 | 288 | ||
289 | $scope.fuelData.companyName = $scope.order.companyName; | 289 | $scope.fuelData.companyName = $scope.order.companyName; |
290 | var aircraftObj =JSON.parse($scope.order.aircraftName); | 290 | var aircraftObj =JSON.parse($scope.order.aircraftName); |
291 | $scope.fuelData.aircraftName = aircraftObj.tail; | 291 | $scope.fuelData.aircraftName = aircraftObj.tail; |
292 | $scope.fuelData.make = aircraftObj.make; | 292 | $scope.fuelData.make = aircraftObj.make; |
293 | $scope.fuelData.model = aircraftObj.model; | 293 | $scope.fuelData.model = aircraftObj.model; |
294 | $scope.fuelData.fuelOn = $scope.order.fuelOn; | 294 | $scope.fuelData.fuelOn = $scope.order.fuelOn; |
295 | $scope.fuelData.invoiced = $scope.order.invoiced; | 295 | $scope.fuelData.invoiced = $scope.order.invoiced; |
296 | $scope.fuelData.volume = $scope.order.volume; | 296 | $scope.fuelData.volume = $scope.order.volume; |
297 | // $scope.fuelData.source = $scope.order.source; | 297 | // $scope.fuelData.source = $scope.order.source; |
298 | 298 | ||
299 | $scope.fuelData.total = $scope.order.total; | 299 | $scope.fuelData.total = $scope.order.total; |
300 | //tier no use | 300 | //tier no use |
301 | $scope.fuelData.tierBreak = $scope.order.tierBreak; | 301 | $scope.fuelData.tierBreak = $scope.order.tierBreak; |
302 | 302 | ||
303 | var obj =JSON.parse($scope.order.priceQuote); | 303 | var obj =JSON.parse($scope.order.priceQuote); |
304 | $scope.fuelData.priceQuote = obj.papTotal; | 304 | $scope.fuelData.priceQuote = obj.papTotal; |
305 | $scope.fuelData.fboCost = obj.cost; | 305 | $scope.fuelData.fboCost = obj.cost; |
306 | $scope.fuelData.productName = obj.productName; | 306 | $scope.fuelData.productName = obj.productName; |
307 | 307 | ||
308 | $scope.fuelData.etaTime = $scope.order.etaTime; | 308 | $scope.fuelData.etaTime = $scope.order.etaTime; |
309 | $scope.fuelData.etdTime = $scope.order.etdTime; | 309 | $scope.fuelData.etdTime = $scope.order.etdTime; |
310 | $scope.fuelData.certificateType = $scope.order.certificateType; | 310 | $scope.fuelData.certificateType = $scope.order.certificateType; |
311 | var currentDate = new Date(); | 311 | var currentDate = new Date(); |
312 | var hours = currentDate.getHours(); | 312 | var hours = currentDate.getHours(); |
313 | var min = currentDate.getMinutes(); | 313 | var min = currentDate.getMinutes(); |
314 | var sec = currentDate.getSeconds(); | 314 | var sec = currentDate.getSeconds(); |
315 | if ($scope.order.upliftDate != '') { | 315 | if ($scope.order.upliftDate != '') { |
316 | $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; | 316 | $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; |
317 | $scope.order.upliftDate = new Date($scope.order.upliftDate); | 317 | $scope.order.upliftDate = new Date($scope.order.upliftDate); |
318 | $scope.fuelData.upliftDate = $scope.order.upliftDate.getTime(); | 318 | $scope.fuelData.upliftDate = $scope.order.upliftDate.getTime(); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | if ($scope.order.departingDate != '') { | 322 | if ($scope.order.departingDate != '') { |
323 | $scope.order.departingDate = $scope.order.departingDate + ' ' + hours + ':' + min + ':' + sec; | 323 | $scope.order.departingDate = $scope.order.departingDate + ' ' + hours + ':' + min + ':' + sec; |
324 | $scope.order.departingDate = new Date($scope.order.departingDate); | 324 | $scope.order.departingDate = new Date($scope.order.departingDate); |
325 | $scope.fuelData.departingDate = $scope.order.departingDate.getTime(); | 325 | $scope.fuelData.departingDate = $scope.order.departingDate.getTime(); |
326 | } | 326 | } |
327 | 327 | ||
328 | if($scope.order.status === null || $scope.order.status === undefined){ | 328 | if($scope.order.status === null || $scope.order.status === undefined){ |
329 | 329 | ||
330 | $scope.fuelData.status = "pending"; //default status | 330 | $scope.fuelData.status = "pending"; //default status |
331 | 331 | ||
332 | }else { | 332 | }else { |
333 | 333 | ||
334 | $scope.fuelData.status = $scope.order.status; | 334 | $scope.fuelData.status = $scope.order.status; |
335 | } | 335 | } |
336 | 336 | ||
337 | if($scope.baseTenant && $scope.contractFuelVendor ){ | 337 | if($scope.baseTenant && $scope.contractFuelVendor ){ |
338 | $scope.fuelData.source = "Tenant/CAA" ; | 338 | $scope.fuelData.source = "Tenant/CAA" ; |
339 | }else if($scope.baseTenant) | 339 | }else if($scope.baseTenant) |
340 | { | 340 | { |
341 | $scope.fuelData.source = "Tenant/Base Customer"; | 341 | $scope.fuelData.source = "Tenant/Base Customer"; |
342 | }else if($scope.contractFuelVendor){ | 342 | }else if($scope.contractFuelVendor){ |
343 | $scope.fuelData.source = "CAA Member"; | 343 | $scope.fuelData.source = "CAA Member"; |
344 | } | 344 | } |
345 | 345 | ||
346 | $scope.dispatchOrder.fuelOrderList.push($scope.fuelData); | 346 | $scope.dispatchOrder.fuelOrderList.push($scope.fuelData); |
347 | // console.log("=====$scope.fueldata======",$scope.fuelData) | 347 | // console.log("=====$scope.fueldata======",$scope.fuelData) |
348 | fuelOrdersService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { | 348 | fuelOrdersService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { |
349 | $scope.showLoader = false; | 349 | $scope.showLoader = false; |
350 | $scope.order = {}; | 350 | $scope.order = {}; |
351 | $scope.dispatchOrder.fuelOrderList = []; | 351 | $scope.dispatchOrder.fuelOrderList = []; |
352 | $('#demo-modal-4').css('display', ''); | 352 | $('#demo-modal-4').css('display', ''); |
353 | $scope.getOrders(); | 353 | $scope.getOrders(); |
354 | toastr.success('Fuel Order Dispatched Successfully', { | 354 | toastr.success('Fuel Order Dispatched Successfully', { |
355 | closeButton: true | 355 | closeButton: true |
356 | }) | 356 | }) |
357 | }) | 357 | }) |
358 | 358 | ||
359 | 359 | ||
360 | } | 360 | } |
361 | 361 | ||
362 | $scope.updateStatus = function(row, status) { | 362 | $scope.updateStatus = function(row, status) { |
363 | 363 | ||
364 | $scope.showLoader = true; | 364 | $scope.showLoader = true; |
365 | $scope.fuelData = {}; | 365 | $scope.fuelData = {}; |
366 | $scope.fuelData.aircraftName = row.aircraftName | 366 | $scope.fuelData.aircraftName = row.aircraftName |
367 | $scope.fuelData.companyName = row.companyName | 367 | $scope.fuelData.companyName = row.companyName |
368 | $scope.fuelData.departingDate = row.departingDate | 368 | $scope.fuelData.departingDate = row.departingDate |
369 | $scope.fuelData.fboCost = row.fboCost | 369 | $scope.fuelData.fboCost = row.fboCost |
370 | $scope.fuelData.id = row.id | 370 | $scope.fuelData.id = row.id |
371 | $scope.fuelData.invoiced = row.invoiced | 371 | $scope.fuelData.invoiced = row.invoiced |
372 | $scope.fuelData.priceQuote = row.priceQuote | 372 | $scope.fuelData.priceQuote = row.priceQuote |
373 | $scope.fuelData.volume = row.requestedVolume | 373 | $scope.fuelData.volume = row.requestedVolume |
374 | $scope.fuelData.source = row.source | 374 | $scope.fuelData.source = row.source |
375 | $scope.fuelData.status = status | 375 | $scope.fuelData.status = status |
376 | $scope.fuelData.tierBreak = row.tierBreak | 376 | $scope.fuelData.tierBreak = row.tierBreak |
377 | $scope.fuelData.total = row.total | 377 | $scope.fuelData.total = row.total |
378 | $scope.fuelData.upliftDate = row.upliftDate | 378 | $scope.fuelData.upliftDate = row.upliftDate |
379 | 379 | ||
380 | $scope.dispatchOrder.fuelOrderList.push($scope.fuelData); | 380 | $scope.dispatchOrder.fuelOrderList.push($scope.fuelData); |
381 | fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) { | 381 | fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) { |
382 | $scope.showLoader = false; | 382 | $scope.showLoader = false; |
383 | $scope.editdata = {}; | 383 | $scope.editdata = {}; |
384 | $scope.fuelData = {}; | 384 | $scope.fuelData = {}; |
385 | $scope.dispatchOrder.fuelOrderList = []; | 385 | $scope.dispatchOrder.fuelOrderList = []; |
386 | $('#demo-modal-5').css('display', ''); | 386 | $('#demo-modal-5').css('display', ''); |
387 | $scope.getOrders(); | 387 | $scope.getOrders(); |
388 | toastr.success('Fuel Order Updated Successfully', { | 388 | toastr.success('Fuel Order Updated Successfully', { |
389 | closeButton: true | 389 | closeButton: true |
390 | }); | 390 | }); |
391 | }) | 391 | }) |
392 | 392 | ||
393 | } | 393 | } |
394 | $scope.fuelData = {}; | 394 | $scope.fuelData = {}; |
395 | $scope.updateData = function() { | 395 | $scope.updateData = function() { |
396 | if($scope.editdata.etaTime != null && $scope.editdata.etdTime != null){ | 396 | if($scope.editdata.etaTime != null && $scope.editdata.etdTime != null){ |
397 | if($scope.editdata.fuelOn != null || $scope.editdata.fuelOn != undefined) { | 397 | if($scope.editdata.fuelOn != null || $scope.editdata.fuelOn != undefined) { |
398 | $scope.showLoader = true; | 398 | $scope.showLoader = true; |
399 | $scope.fuelData.aircraftName = $scope.editdata.aircraftName; | 399 | $scope.fuelData.aircraftName = $scope.editdata.aircraftName; |
400 | $scope.fuelData.companyName = $scope.editdata.companyName; | 400 | $scope.fuelData.companyName = $scope.editdata.companyName; |
401 | $scope.fuelData.fboCost = $scope.editdata.fboCost; | 401 | $scope.fuelData.fboCost = $scope.editdata.fboCost; |
402 | $scope.fuelData.id = $scope.editdata.id; | 402 | $scope.fuelData.id = $scope.editdata.id; |
403 | $scope.fuelData.invoiced = $scope.editdata.invoiced; | 403 | $scope.fuelData.invoiced = $scope.editdata.invoiced; |
404 | $scope.fuelData.priceQuote = $scope.editdata.priceQuote; | 404 | $scope.fuelData.priceQuote = $scope.editdata.priceQuote; |
405 | $scope.fuelData.volume = $scope.editdata.requestedVolume; | 405 | $scope.fuelData.volume = $scope.editdata.requestedVolume; |
406 | $scope.fuelData.source = $scope.editdata.source; | 406 | $scope.fuelData.source = $scope.editdata.source; |
407 | $scope.fuelData.status = $scope.editdata.status; | 407 | $scope.fuelData.status = $scope.editdata.status; |
408 | $scope.fuelData.tierBreak = $scope.editdata.tierBreak; | 408 | $scope.fuelData.tierBreak = $scope.editdata.tierBreak; |
409 | $scope.fuelData.total = $scope.editdata.total; | 409 | $scope.fuelData.total = $scope.editdata.total; |
410 | 410 | ||
411 | $scope.editdata.upliftDateString = new Date($scope.editdata.upliftDateString); | 411 | $scope.editdata.upliftDateString = new Date($scope.editdata.upliftDateString); |
412 | $scope.editdata.upliftDateString = $scope.editdata.upliftDateString.getTime(); | 412 | $scope.editdata.upliftDateString = $scope.editdata.upliftDateString.getTime(); |
413 | 413 | ||
414 | $scope.editdata.departingDateString = new Date($scope.editdata.departingDateString); | 414 | $scope.editdata.departingDateString = new Date($scope.editdata.departingDateString); |
415 | $scope.editdata.departingDateString = $scope.editdata.departingDateString.getTime(); | 415 | $scope.editdata.departingDateString = $scope.editdata.departingDateString.getTime(); |
416 | 416 | ||
417 | $scope.fuelData.upliftDate = $scope.editdata.upliftDateString; | 417 | $scope.fuelData.upliftDate = $scope.editdata.upliftDateString; |
418 | $scope.fuelData.departingDate = $scope.editdata.departingDateString; | 418 | $scope.fuelData.departingDate = $scope.editdata.departingDateString; |
419 | $scope.fuelData.productName = $scope.editdata.productName; | 419 | $scope.fuelData.productName = $scope.editdata.productName; |
420 | /*$scope.fuelData.etaTime = $scope.editdata.etaTime.toLocaleTimeString(); | 420 | /*$scope.fuelData.etaTime = $scope.editdata.etaTime.toLocaleTimeString(); |
421 | $scope.fuelData.etdTime = $scope.editdata.etdTime.toLocaleTimeString();*/ | 421 | $scope.fuelData.etdTime = $scope.editdata.etdTime.toLocaleTimeString();*/ |
422 | $scope.fuelData.etaTime = $scope.editdata.etaTime; | 422 | $scope.fuelData.etaTime = $scope.editdata.etaTime; |
423 | $scope.fuelData.etdTime = $scope.editdata.etdTime; | 423 | $scope.fuelData.etdTime = $scope.editdata.etdTime; |
424 | $scope.fuelData.certificateType = $scope.editdata.certificateType; | 424 | $scope.fuelData.certificateType = $scope.editdata.certificateType; |
425 | $scope.fuelData.fuelOn = $scope.editdata.fuelOn; | 425 | $scope.fuelData.fuelOn = $scope.editdata.fuelOn; |
426 | 426 | ||
427 | $scope.dispatchOrder.fuelOrderList.push($scope.fuelData); | 427 | $scope.dispatchOrder.fuelOrderList.push($scope.fuelData); |
428 | // console.log("====fueldata===",$scope.dispatchOrder); | 428 | // console.log("====fueldata===",$scope.dispatchOrder); |
429 | fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) { | 429 | fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) { |
430 | // console.log('result', result); | 430 | // console.log('result', result); |
431 | $scope.showLoader = false; | 431 | $scope.showLoader = false; |
432 | $scope.editdata = {}; | 432 | $scope.editdata = {}; |
433 | $('#demo-modal-5').css('display', ''); | 433 | $('#demo-modal-5').css('display', ''); |
434 | $scope.getOrders(); | 434 | $scope.getOrders(); |
435 | toastr.success('Fuel Order Updated Successfully', { | 435 | toastr.success('Fuel Order Updated Successfully', { |
436 | closeButton: true | 436 | closeButton: true |
437 | }) | 437 | }) |
438 | }) | 438 | }) |
439 | 439 | ||
440 | 440 | ||
441 | } else{ | 441 | } else{ |
442 | { | 442 | { |
443 | toastr.error('Please select fuelOn.', { | 443 | toastr.error('Please select fuelOn.', { |
444 | closeButton: true | 444 | closeButton: true |
445 | }) | 445 | }) |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | }else | 449 | }else |
450 | { | 450 | { |
451 | toastr.error('Please select Arrival Time and Departure time both.', { | 451 | toastr.error('Please select Arrival Time and Departure time both.', { |
452 | closeButton: true | 452 | closeButton: true |
453 | }) | 453 | }) |
454 | } | 454 | } |
455 | 455 | ||
456 | } | 456 | } |
457 | 457 | ||
458 | $scope.getAircraft = function(company){ | 458 | $scope.getAircraft = function(company){ |
459 | 459 | ||
460 | $scope.selectedCompanyName = company; | 460 | $scope.selectedCompanyName = company; |
461 | //$scope.showLoader = true; | 461 | //$scope.showLoader = true; |
462 | for (var i = 0; i < $scope.companyList.length; i++) { | 462 | for (var i = 0; i < $scope.companyList.length; i++) { |
463 | if ($scope.companyList[i].companyName == company) { | 463 | if ($scope.companyList[i].companyName == company) { |
464 | $scope.order.certificateType = $scope.companyList[i].certificateType; | 464 | $scope.order.certificateType = $scope.companyList[i].certificateType; |
465 | $scope.baseTenant = $scope.companyList[i].baseTenant; | 465 | $scope.baseTenant = $scope.companyList[i].baseTenant; |
466 | $scope.contractFuelVendor = $scope.companyList[i].contractFuelVendor; | 466 | $scope.contractFuelVendor = $scope.companyList[i].contractFuelVendor; |
467 | $scope.fuelerlinxCustomer = $scope.companyList[i].fuelerlinxCustomer; | 467 | $scope.fuelerlinxCustomer = $scope.companyList[i].fuelerlinxCustomer; |
468 | 468 | ||
469 | if($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null){ | 469 | if($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null){ |
470 | fuelOrdersService.getFuelCost($scope.companyList[i].id).then(function(margins) { | 470 | fuelOrdersService.getFuelCost($scope.companyList[i].id).then(function(margins) { |
471 | $scope.marginList = margins; | 471 | $scope.marginList = margins; |
472 | }) | 472 | }) |
473 | } else if ($scope.companyList[i].margin != null || $scope.companyList[i].marginAVGAS == null) { | 473 | } else if ($scope.companyList[i].margin != null || $scope.companyList[i].marginAVGAS == null) { |
474 | fuelOrdersService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) { | 474 | fuelOrdersService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) { |
475 | $scope.marginList = margins; | 475 | $scope.marginList = margins; |
476 | }) | 476 | }) |
477 | } else if ($scope.companyList[i].margin == null || $scope.companyList[i].marginAVGAS != null) { | 477 | } else if ($scope.companyList[i].margin == null || $scope.companyList[i].marginAVGAS != null) { |
478 | fuelOrdersService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) { | 478 | fuelOrdersService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) { |
479 | $scope.marginList = margins; | 479 | $scope.marginList = margins; |
480 | }) | 480 | }) |
481 | } | 481 | } |
482 | $scope.selectedCompanyId = $scope.companyList[i].id; | 482 | $scope.selectedCompanyId = $scope.companyList[i].id; |
483 | $scope.marginId = $scope.companyList[i].margin.id; | 483 | $scope.marginId = $scope.companyList[i].margin.id; |
484 | if ($scope.selectedCompanyId != '') { | 484 | if ($scope.selectedCompanyId != '') { |
485 | fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { | 485 | fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { |
486 | $scope.aircraftList = aircraft; | 486 | $scope.aircraftList = aircraft; |
487 | }) | 487 | }) |
488 | } | 488 | } |
489 | if ($scope.marginId != '') { | 489 | if ($scope.marginId != '') { |
490 | fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) { | 490 | fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) { |
491 | $scope.tierList = tiers; | 491 | $scope.tierList = tiers; |
492 | // $scope.showLoader = false; | 492 | // $scope.showLoader = false; |
493 | }) | 493 | }) |
494 | }else{ | 494 | }else{ |
495 | // $scope.showLoader = false; | 495 | // $scope.showLoader = false; |
496 | } | 496 | } |
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | } | 500 | } |
501 | 501 | ||
502 | 502 | ||
503 | 503 | ||
504 | $scope.cancelData = function() { | 504 | $scope.cancelData = function() { |
505 | $('#demo-modal-4').css('display', ''); | 505 | $('#demo-modal-4').css('display', ''); |
506 | } | 506 | } |
507 | $scope.canceleditdata = function() { | 507 | $scope.canceleditdata = function() { |
508 | $('#demo-modal-5').css('display', ''); | 508 | $('#demo-modal-5').css('display', ''); |
509 | } | 509 | } |
510 | 510 | ||
511 | 511 | ||
512 | 512 | ||
513 | $scope.companyList = {}; | 513 | $scope.companyList = {}; |
514 | 514 | ||
515 | fuelOrdersService.getAllCompanies().then(function(result) { | 515 | fuelOrdersService.getAllCompanies().then(function(result) { |
516 | $scope.showLoader = true; | 516 | $scope.showLoader = true; |
517 | $scope.companyList = result; | 517 | $scope.companyList = result; |
518 | $scope.showLoader = false; | 518 | $scope.showLoader = false; |
519 | }) | 519 | }) |
520 | 520 | ||
521 | /*Add a company services API used from customersService */ | 521 | /*Add a company services API used from customersService */ |
522 | getCompanyName(); | 522 | getCompanyName(); |
523 | function getCompanyName(){ | 523 | function getCompanyName(){ |
524 | CustomersService.getCompanyName().then(function(result) { | 524 | CustomersService.getCompanyName().then(function(result) { |
525 | $scope.showLoader = true; | 525 | $scope.showLoader = true; |
526 | $scope.compNameList = result; | 526 | $scope.compNameList = result; |
527 | $scope.showLoader = false; | 527 | $scope.showLoader = false; |
528 | }) | 528 | }) |
529 | } | 529 | } |
530 | 530 | ||
531 | $scope.marginFilterOptions = []; | 531 | $scope.marginFilterOptions = []; |
532 | CustomersService.getJetMargin($scope.userProfileId).then(function(result) { | 532 | CustomersService.getJetMargin($scope.userProfileId).then(function(result) { |
533 | $scope.showLoader = true; | 533 | $scope.showLoader = true; |
534 | $scope.jetMarginList = result; | 534 | $scope.jetMarginList = result; |
535 | $scope.marginFilterOptions.push({ | 535 | $scope.marginFilterOptions.push({ |
536 | 'id': '', 'title': 'Show All' | 536 | 'id': '', 'title': 'Show All' |
537 | }); | 537 | }); |
538 | for (var i = 0; i < result.length; i++) { | 538 | for (var i = 0; i < result.length; i++) { |
539 | $scope.marginFilterOptions.push({ | 539 | $scope.marginFilterOptions.push({ |
540 | 'id': result[i].id, | 540 | 'id': result[i].id, |
541 | 'title': result[i].marginName | 541 | 'title': result[i].marginName |
542 | }) | 542 | }) |
543 | } | 543 | } |
544 | $scope.showLoader = false; | 544 | $scope.showLoader = false; |
545 | }) | 545 | }) |
546 | 546 | ||
547 | CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { | 547 | CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { |
548 | $scope.avgsMarginList = result; | 548 | $scope.avgsMarginList = result; |
549 | }) | 549 | }) |
550 | 550 | ||
551 | $scope.showCompanyError = false; | 551 | $scope.showCompanyError = false; |
552 | $scope.showMarginError = false; | 552 | $scope.showMarginError = false; |
553 | 553 | ||
554 | $scope.removeValidation = function(){ | 554 | $scope.removeValidation = function(){ |
555 | $scope.showCompanyError = false; | 555 | $scope.showCompanyError = false; |
556 | $('.companyNameInput').removeClass('customErrorInput'); | 556 | $('.companyNameInput').removeClass('customErrorInput'); |
557 | if($scope.data.companyName == 'undefined' || $scope.data.companyName == '') { | 557 | if($scope.data.companyName == 'undefined' || $scope.data.companyName == '') { |
558 | $('.companyNameInput').addClass('customErrorInput'); | 558 | $('.companyNameInput').addClass('customErrorInput'); |
559 | $scope.showCompanyError = true; | 559 | $scope.showCompanyError = true; |
560 | } | 560 | } |
561 | } | 561 | } |
562 | 562 | ||
563 | $scope.removeMarginValidation = function(){ | 563 | $scope.removeMarginValidation = function(){ |
564 | $scope.showMarginError = false; | 564 | $scope.showMarginError = false; |
565 | $('.marginSelectBox').removeClass('customErrorInput'); | 565 | $('.marginSelectBox').removeClass('customErrorInput'); |
566 | } | 566 | } |
567 | 567 | ||
568 | getData(); | 568 | getData(); |
569 | function getData(){ | 569 | function getData(){ |
570 | $scope.showLoader = true; | 570 | $scope.showLoader = true; |
571 | CustomersService.getAircraftMake().then(function(result) { | 571 | CustomersService.getAircraftMake().then(function(result) { |
572 | $scope.aircraftMakeList = result; | 572 | $scope.aircraftMakeList = result; |
573 | $scope.showLoader = false; | 573 | $scope.showLoader = false; |
574 | }) | 574 | }) |
575 | } | 575 | } |
576 | var companyData; | 576 | var companyData; |
577 | $scope.addFirstData = function(sel, step){ | 577 | $scope.addFirstData = function(sel, step){ |
578 | $scope.showLoader = true; | 578 | $scope.showLoader = true; |
579 | if($scope.data.companyName == undefined){ | 579 | if($scope.data.companyName == undefined){ |
580 | $scope.showCompanyError = true; | 580 | $scope.showCompanyError = true; |
581 | $('.companyNameInput').addClass('customErrorInput'); | 581 | $('.companyNameInput').addClass('customErrorInput'); |
582 | }else if($scope.data.masterMargin == undefined){ | 582 | }else if($scope.data.masterMargin == undefined){ |
583 | $scope.showMarginError = true; | 583 | $scope.showMarginError = true; |
584 | $('.marginSelectBox').addClass('customErrorInput'); | 584 | $('.marginSelectBox').addClass('customErrorInput'); |
585 | }else{ | 585 | }else{ |
586 | $scope.aircraftDetails = [{ | 586 | $scope.aircraftDetails = [{ |
587 | 'tail':'', | 587 | 'tail':'', |
588 | 'make': '', | 588 | 'make': '', |
589 | 'model': '', | 589 | 'model': '', |
590 | 'sizeId' : '', | 590 | 'sizeId' : '', |
591 | 'marginId': $scope.data.masterMargin, | 591 | 'marginId': $scope.data.masterMargin, |
592 | 'avgasMarginId': $scope.data.avgasMargin | 592 | 'avgasMarginId': $scope.data.avgasMargin |
593 | }]; | 593 | }]; |
594 | 594 | ||
595 | $(sel).trigger('next.m.' + step); | 595 | $(sel).trigger('next.m.' + step); |
596 | getData(); | 596 | getData(); |
597 | } | 597 | } |
598 | $scope.showLoader = false; | 598 | $scope.showLoader = false; |
599 | } | 599 | } |
600 | $scope.addNew = function(){ | 600 | $scope.addNew = function(){ |
601 | $scope.showLoader = true; | 601 | $scope.showLoader = true; |
602 | $scope.aircraftDetails.push({ | 602 | $scope.aircraftDetails.push({ |
603 | 'tail':'', | 603 | 'tail':'', |
604 | 'make': '', | 604 | 'make': '', |
605 | 'model': '', | 605 | 'model': '', |
606 | 'sizeId' : '', | 606 | 'sizeId' : '', |
607 | 'marginId': $scope.data.masterMargin, | 607 | 'marginId': $scope.data.masterMargin, |
608 | 'avgasMarginId': $scope.data.avgasMargin | 608 | 'avgasMarginId': $scope.data.avgasMargin |
609 | }); | 609 | }); |
610 | $scope.showLoader = false; | 610 | $scope.showLoader = false; |
611 | }; | 611 | }; |
612 | 612 | ||
613 | $scope.aircraft = {}; | 613 | $scope.aircraft = {}; |
614 | $scope.getModal = function(makeId, index){ | 614 | $scope.getModal = function(makeId, index){ |
615 | $scope.showLoader = true; | 615 | $scope.showLoader = true; |
616 | $scope.aircraft.make = makeId; | 616 | $scope.aircraft.make = makeId; |
617 | CustomersService.getModal($scope.aircraft.make).then(function(result) { | 617 | CustomersService.getModal($scope.aircraft.make).then(function(result) { |
618 | $scope.showLoader = false; | 618 | $scope.showLoader = false; |
619 | $scope.aircraftDetails[index].aircraftModalList = result; | 619 | $scope.aircraftDetails[index].aircraftModalList = result; |
620 | //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; | 620 | //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; |
621 | }) | 621 | }) |
622 | } | 622 | } |
623 | 623 | ||
624 | $scope.getSize = function(model, index){ | 624 | $scope.getSize = function(model, index){ |
625 | $scope.showLoader = true; | 625 | $scope.showLoader = true; |
626 | CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { | 626 | CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { |
627 | $scope.showLoader = false; | 627 | $scope.showLoader = false; |
628 | $scope.aircraftDetails[index].aircraftSizeList = result; | 628 | $scope.aircraftDetails[index].aircraftSizeList = result; |
629 | //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0]; | 629 | //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0]; |
630 | }) | 630 | }) |
631 | } | 631 | } |
632 | 632 | ||
633 | $scope.aircraftListData = {}; | 633 | $scope.aircraftListData = {}; |
634 | $scope.addData = []; | 634 | $scope.addData = []; |
635 | 635 | ||
636 | $scope.saveCompanyData = function(){ | 636 | $scope.saveCompanyData = function(){ |
637 | CustomersService.addCompany($scope.data).then(function(result) { | 637 | CustomersService.addCompany($scope.data).then(function(result) { |
638 | $scope.accountId = result; | 638 | $scope.accountId = result; |
639 | $scope.aircraft.accountId = $scope.accountId; | 639 | $scope.aircraft.accountId = $scope.accountId; |
640 | 640 | ||
641 | for(var i=0; i<$scope.aircraftDetails.length;i++){ | 641 | for(var i=0; i<$scope.aircraftDetails.length;i++){ |
642 | $scope.addData.push({ | 642 | $scope.addData.push({ |
643 | 'tail': $scope.aircraftDetails[i].tail, | 643 | 'tail': $scope.aircraftDetails[i].tail, |
644 | 'make': $scope.aircraftDetails[i].make, | 644 | 'make': $scope.aircraftDetails[i].make, |
645 | 'model': $scope.aircraftDetails[i].model, | 645 | 'model': $scope.aircraftDetails[i].model, |
646 | 'sizeId' : $scope.aircraftDetails[i].sizeId, | 646 | 'sizeId' : $scope.aircraftDetails[i].sizeId, |
647 | 'marginId': $scope.aircraftDetails[i].marginId, | 647 | 'marginId': $scope.aircraftDetails[i].marginId, |
648 | 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId | 648 | 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId |
649 | }); | 649 | }); |
650 | } | 650 | } |
651 | $scope.aircraftListData.aircraftList = $scope.addData; | 651 | $scope.aircraftListData.aircraftList = $scope.addData; |
652 | $scope.aircraftListData.accountId = $scope.aircraft.accountId; | 652 | $scope.aircraftListData.accountId = $scope.aircraft.accountId; |
653 | 653 | ||
654 | if($scope.aircraftListData.aircraftList[0].tail == "" || $scope.aircraftListData.aircraftList[0].make == null || $scope.aircraftListData.aircraftList[0].model == null){ | 654 | if($scope.aircraftListData.aircraftList[0].tail == "" || $scope.aircraftListData.aircraftList[0].make == null || $scope.aircraftListData.aircraftList[0].model == null){ |
655 | $scope.aircraftListData.aircraftList = []; | 655 | $scope.aircraftListData.aircraftList = []; |
656 | } | 656 | } |
657 | 657 | ||
658 | CustomersService.addAircraft($scope.aircraftListData).then(function(result) { | 658 | CustomersService.addAircraft($scope.aircraftListData).then(function(result) { |
659 | 659 | ||
660 | if(result != null && result.success){ | 660 | if(result != null && result.success){ |
661 | toastr.success(''+result.success+'', { | 661 | toastr.success(''+result.success+'', { |
662 | closeButton: true | 662 | closeButton: true |
663 | }) | 663 | }) |
664 | $('#demo-modal-3').modal('hide'); | 664 | $('#demo-modal-3').modal('hide'); |
665 | getAllCompanies(); | 665 | getAllCompanies(); |
666 | }else{ | 666 | }else{ |
667 | toastr.error(''+result.statusText+'', { | 667 | toastr.error(''+result.statusText+'', { |
668 | closeButton: true | 668 | closeButton: true |
669 | }) | 669 | }) |
670 | } | 670 | } |
671 | }); | 671 | }); |
672 | 672 | ||
673 | }) | 673 | }) |
674 | 674 | ||
675 | 675 | ||
676 | } | 676 | } |
677 | 677 | ||
678 | $scope.checkJetWithTail = function(tail, index){ | 678 | $scope.checkJetWithTail = function(tail, index){ |
679 | 679 | ||
680 | ViewCompanyService.checkJetType(tail).then(function(result) { | 680 | ViewCompanyService.checkJetType(tail).then(function(result) { |
681 | if(result.jetA == "true"){ | 681 | if(result.jetA == "true"){ |
682 | $scope.jetShow[index] = false; | 682 | $scope.jetShow[index] = false; |
683 | $scope.marginShow[index] = true; | 683 | $scope.marginShow[index] = true; |
684 | }else{ | 684 | }else{ |
685 | $scope.jetShow[index] = true; | 685 | $scope.jetShow[index] = true; |
686 | $scope.marginShow[index] = false; | 686 | $scope.marginShow[index] = false; |
687 | } | 687 | } |
688 | }) | 688 | }) |
689 | } | 689 | } |
690 | 690 | ||
691 | $scope.etaTimeList=[]; | 691 | $scope.etaTimeList=[]; |
692 | $scope.etdTimeList =[]; | 692 | $scope.etdTimeList =[]; |
693 | 693 | ||
694 | $scope.sourceList = [{source:"Direct Jet-A"},{source:"Direct AVGAS 100LL"}]; | 694 | $scope.sourceList = [{source:"Direct Jet-A"},{source:"Direct AVGAS 100LL"}]; |
695 | $scope.etaTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, | 695 | $scope.etaTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, |
696 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, | 696 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, |
697 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, | 697 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, |
698 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, | 698 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, |
699 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, | 699 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, |
700 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; | 700 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; |
701 | 701 | ||
702 | $scope.etdTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, | 702 | $scope.etdTimeList = [{time:"12:00 AM"},{time:"12:30 AM"},{time:"01:00 AM"},{time:"01:30 AM"},{time:"02:00 AM"},{time:"02:30 AM"},{time:"03:00 AM"},{time:"03:30 AM"}, |
703 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, | 703 | {time:"04:00 AM"},{time:"04:30 AM"},{time:"05:00 AM"},{time:"05:30 AM"},{time:"06:00 AM"},{time:"06:30 AM"},{time:"07:00 AM"},{time:"07:30 AM"}, |
704 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, | 704 | {time:"08:00 AM"},{time:"08:30 AM"},{time:"09:00 AM"},{time:"09:30 AM"},{time:"10:00 AM"},{time:"10:30 AM"},{time:"11:00 AM"},{time:"11:30 AM"}, |
705 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, | 705 | {time:"12:00 PM"},{time:"12:30 PM"},{time:"01:00 PM"},{time:"01:30 PM"},{time:"02:00 PM"},{time:"02:30 PM"},{time:"03:00 PM"},{time:"03:30 PM"}, |
706 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, | 706 | {time:"04:00 PM"},{time:"04:30 PM"},{time:"05:00 PM"},{time:"05:30 PM"},{time:"06:00 PM"},{time:"06:30 PM"},{time:"07:00 PM"},{time:"07:30 PM"}, |
707 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; | 707 | {time:"08:00 PM"},{time:"08:30 PM"},{time:"9:00 PM"},{time:"09:30 PM"},{time:"10:00 PM"},{time:"10:30 PM"},{time:"11:00 PM"},{time:"11:30 PM"},]; |
708 | 708 | ||
709 | $scope.data = {}; | 709 | $scope.data = {}; |
710 | 710 | ||
711 | 711 | ||
712 | 712 | ||
713 | } | 713 | } |