Commit e33b4556c46cce5b8ce1afce9bfbaea261b212f6

Authored by Kuldeep Arora
1 parent bd0c7fcc7f
Exists in master

bugs resolved

app/partials/fuelOrders/fuelOrders.controller.js
... ... @@ -2,22 +2,27 @@
2 2  
3 3 angular.module('acufuel')
4 4  
5   -.controller('fuelOrdersController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'NgTableParams','fuelOrdersService', fuelOrdersController]);
  5 +.controller('fuelOrdersController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'NgTableParams','fuelOrdersService','CustomersService','ViewCompanyService', fuelOrdersController]);
6 6  
7   -function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgTableParams,fuelOrdersService) {
  7 +function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgTableParams,fuelOrdersService,CustomersService,ViewCompanyService) {
8 8  
9   - $scope.showFuelOrderModal = false;
10   - $scope.optionSelected;
11   - $scope.orderdata = {}
12   - $scope.showLoader = false;
  9 + $scope.showFuelOrderModal = false;
  10 + $scope.optionSelected;
  11 + $scope.orderdata = {}
  12 + $scope.showLoader = false;
  13 + $scope.jetShow = [];
  14 + $scope.marginShow = [];
  15 +
  16 + $scope.jetShow[0] = true;
  17 + $scope.marginShow[0] = true;
13 18  
14   - $scope.data = {};
15   - $scope.order = {};
16   - $scope.dispatchOrder = {};
17   - $scope.dispatchOrder.fuelOrderList = [];
  19 + $scope.data = {};
  20 + $scope.order = {};
  21 + $scope.dispatchOrder = {};
  22 + $scope.dispatchOrder.fuelOrderList = [];
18 23  
19   - $scope.statusFilterOptions = [];
20   - $scope.statusFilterOptions.push({
  24 + $scope.statusFilterOptions = [];
  25 + $scope.statusFilterOptions.push({
21 26 'id': '', 'title': 'Show All'
22 27 },{
23 28 'id': 'pending', 'title': 'Pending'
... ... @@ -33,11 +38,51 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
33 38  
34 39 );
35 40  
  41 + getAllCompanies();
  42 +
  43 + function getAllCompanies(){
  44 + fuelOrdersService.getAllCompanies().then(function(result) {
  45 + // console.log('log', result);
  46 + $scope.companyList = result;
  47 + for (var i = 0; i < $scope.companyList.length; i++) {
  48 + if ($scope.companyList[i].companyContact != null) {
  49 + if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) {
  50 + $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber;
  51 + }
  52 + }
  53 + if ($scope.companyList[i].primaryContact != null) {
  54 + if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) {
  55 + $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName;
  56 + }
  57 + }
  58 + if ($scope.companyList[i].margin != null) {
  59 + if ($scope.companyList[i].margin.marginName != null) {
  60 + $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id;
  61 + }
  62 + }
  63 + }
  64 + $scope.displayCompanyList = new NgTableParams({
  65 + page: 1,
  66 + count: 10,
  67 + }, {
  68 + data: $scope.companyList
  69 + });
  70 + $scope.showLoader = false;
  71 + })
  72 + }
  73 +
  74 +
  75 + $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId'))
  76 + $scope.reset2 = function(){
  77 + $("input").val("");
  78 + $scope.removeMarginValidation();
  79 + }
  80 +
36 81 function colourFunction() {
37 82 var myselect = document.getElementById('colorfulSelectbox'),
38 83 colour = myselect.options[myselect.selectedIndex].className;
39 84 myselect.style.background = colour;
40   - console.log('colour', myselect);
  85 + // console.log('colour', myselect);
41 86 myselect.blur();
42 87 }
43 88  
... ... @@ -72,7 +117,7 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
72 117 var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear()
73 118 // str = str.slice(4,16)
74 119 $scope.orderdata[i].upliftDateString = str
75   - console.log(str);
  120 + // console.log(str);
76 121  
77 122 }
78 123  
... ... @@ -88,10 +133,10 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
88 133 for (var i = 0; i < myselect.length; i++) {
89 134 var colourIndex = $(myselect[i]).prop('selectedIndex');
90 135 colourIndex = colourIndex + 1;
91   - console.log(colourIndex);
  136 + // console.log(colourIndex);
92 137 var getColor = $('.colorfulSelectbox option:nth-child('+colourIndex+')').css('color');
93 138 $(myselect[i]).css('background-color', getColor);
94   - console.log('colour', getColor);
  139 + // console.log('colour', getColor);
95 140 myselect[i].blur();
96 141 }
97 142  
... ... @@ -121,48 +166,48 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
121 166 })
122 167 }
123 168 }
124   - $scope.attachmentrowid = ""
125   -
126   -
127   - $scope.attachment = function(id, value, url) {
128   - console.log(id, value)
129   - $scope.attachmentrowid = id
130   - // $scope.attachmentdeleteid = attachdeleteid
131   - if(value == 'uploadAttachment'){
132   - $('#demo-modal-6').css('display', 'block');
133   - }else if(value == 'viewAttachment'){
134   - var win = window.open(url, '_blank');
135   - win.focus();
136   - }else if(value == 'deleteAttachment'){
137   - $('#delete1').css('display', 'block');
138   - }
139   - }
  169 + $scope.attachmentrowid = ""
140 170  
141   - $scope.cancelDeleteAttachment = function() {
142   - $('#delete1').css('display', '');
143   - }
  171 +
  172 + $scope.attachment = function(id, value, url) {
  173 + // console.log(id, value)
  174 + $scope.attachmentrowid = id
  175 + // $scope.attachmentdeleteid = attachdeleteid
  176 + if(value == 'uploadAttachment'){
  177 + $('#demo-modal-6').css('display', 'block');
  178 + }else if(value == 'viewAttachment'){
  179 + var win = window.open(url, '_blank');
  180 + win.focus();
  181 + }else if(value == 'deleteAttachment'){
  182 + $('#delete1').css('display', 'block');
  183 + }
  184 + }
  185 +
  186 + $scope.cancelDeleteAttachment = function() {
  187 + $('#delete1').css('display', '');
  188 + }
144 189  
145   - $scope.deleteAttachment = function() {
146   - $scope.showLoader = true;
147   - fuelOrdersService.deleteAttachment($scope.attachmentrowid).then(function(result) {
148   - console.log(result, $scope.attachmentrowid)
  190 + $scope.deleteAttachment = function() {
  191 + $scope.showLoader = true;
  192 + fuelOrdersService.deleteAttachment($scope.attachmentrowid).then(function(result) {
  193 + // console.log(result, $scope.attachmentrowid)
149 194  
150   - if(result.success){
151   - toastr.success(''+result.success+'', {
152   - closeButton: true
153   - })
154   - }
155   - })
156   - $scope.showLoader = false;
157   - $('#delete1').css('display', '');
158   - }
  195 + if(result.success){
  196 + toastr.success(''+result.success+'', {
  197 + closeButton: true
  198 + })
  199 + }
  200 + })
  201 + $scope.showLoader = false;
  202 + $('#delete1').css('display', '');
  203 + }
159 204  
160 205 $scope.saveUploadAttachment = function(attachmentData) {
161 206 $scope.showLoader = true;
162 207 $scope.data.media = attachmentData
163 208 $scope.data.id = $scope.attachmentrowid
164 209 fuelOrdersService.uploadAttachment($scope.data).then(function(result) {
165   - console.log(result)
  210 + // console.log(result)
166 211 if(result){
167 212 // console.log(result.success)
168 213 toastr.success(''+"Upload Successful"+'', {
... ... @@ -175,73 +220,73 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
175 220 $('#demo-modal-6').css('display', 'none');
176 221 }
177 222  
178   - $scope.cancelUploadAttachment = function() {
179   - $('#demo-modal-6').css('display', 'none');
180   - }
181   -
182   - $scope.editdata = {};
183   -
  223 + $scope.cancelUploadAttachment = function() {
  224 + $('#demo-modal-6').css('display', 'none');
  225 + }
184 226  
185   - $scope.editTableRow = function(rowData){
186   - console.log('row data', rowData);
187   - $scope.editdata = rowData;
188   - $('#demo-modal-5').css('display', 'block');
189   - }
  227 + $scope.editdata = {};
  228 +
190 229  
191   - $scope.updateTotal = function(value, valueOf){
192   - if(valueOf == 'v'){
193   - $scope.editdata.total = value * $scope.editdata.invoiced
194   - }else if(valueOf == 'i'){
195   - $scope.editdata.total = $scope.editdata.requestedVolume * value
  230 + $scope.editTableRow = function(rowData){
  231 + // console.log('row data', rowData);
  232 + $scope.editdata = rowData;
  233 + $('#demo-modal-5').css('display', 'block');
196 234 }
197   - }
198 235  
199   - $scope.addTotal = function(value, valueOf){
200   - if(valueOf == 'v'){
201   - $scope.order.total = value * $scope.order.invoiced
202   - }else if(valueOf == 'i'){
203   - $scope.order.total = $scope.order.volume * value
  236 + $scope.updateTotal = function(value, valueOf){
  237 + if(valueOf == 'v'){
  238 + $scope.editdata.total = value * $scope.editdata.invoiced
  239 + }else if(valueOf == 'i'){
  240 + $scope.editdata.total = $scope.editdata.requestedVolume * value
  241 + }
204 242 }
205   - }
  243 +
  244 + $scope.addTotal = function(value, valueOf){
  245 + if(valueOf == 'v'){
  246 + $scope.order.total = value * $scope.order.invoiced
  247 + }else if(valueOf == 'i'){
  248 + $scope.order.total = $scope.order.volume * value
  249 + }
  250 + }
206 251  
207 252 $scope.addData = function() {
208   - $scope.showLoader = true;
  253 + $scope.showLoader = true;
209 254  
210   - if ($scope.order.upliftDate != '') {
211   - $scope.order.upliftDate = new Date($scope.order.upliftDate);
212   - $scope.order.upliftDate = $scope.order.upliftDate.getTime();
213   - }
214   - if ($scope.order.departingDate != '') {
215   - $scope.order.departingDate = new Date($scope.order.departingDate);
216   - $scope.order.departingDate = $scope.order.departingDate.getTime();
217   - }
218   - console.log($scope.order.quotePrice);
219   - var obj =JSON.parse($scope.order.priceQuote);
220   - console.log('obj.papMargin',obj.papMargin);
221   - $scope.order.priceQuote = obj.papMargin;
222   -
223   - $scope.fuelData = {};
224   - $scope.fuelData.aircraftName = $scope.order.aircraftName
225   - $scope.fuelData.companyName = $scope.order.companyName
226   - $scope.fuelData.departingDate = $scope.order.departingDate
227   - $scope.fuelData.fboCost = $scope.order.fboCost
228   - $scope.fuelData.id = $scope.order.id
229   - $scope.fuelData.invoiced = $scope.order.invoiced
230   - $scope.fuelData.priceQuote = $scope.order.priceQuote
231   - $scope.fuelData.volume = $scope.order.volume
232   - $scope.fuelData.source = $scope.order.source
233   - $scope.fuelData.status = $scope.order.status
234   - $scope.fuelData.tierBreak = $scope.order.tierBreak
235   - $scope.fuelData.total = $scope.order.total
236   - $scope.fuelData.upliftDate = $scope.order.upliftDate
237   - $scope.fuelData.companyId = $scope.selectedCompanyId;
238   -
  255 + if ($scope.order.upliftDate != '') {
  256 + $scope.order.upliftDate = new Date($scope.order.upliftDate);
  257 + $scope.order.upliftDate = $scope.order.upliftDate.getTime();
  258 + }
  259 + if ($scope.order.departingDate != '') {
  260 + $scope.order.departingDate = new Date($scope.order.departingDate);
  261 + $scope.order.departingDate = $scope.order.departingDate.getTime();
  262 + }
  263 + // console.log($scope.order.quotePrice);
  264 + var obj =JSON.parse($scope.order.priceQuote);
  265 + // console.log('obj.papMargin',obj.papMargin);
  266 + $scope.order.priceQuote = obj.papMargin;
  267 +
  268 + $scope.fuelData = {};
  269 + $scope.fuelData.aircraftName = $scope.order.aircraftName
  270 + $scope.fuelData.companyName = $scope.order.companyName
  271 + $scope.fuelData.departingDate = $scope.order.departingDate
  272 + $scope.fuelData.fboCost = $scope.order.fboCost
  273 + $scope.fuelData.id = $scope.order.id
  274 + $scope.fuelData.invoiced = $scope.order.invoiced
  275 + $scope.fuelData.priceQuote = $scope.order.priceQuote
  276 + $scope.fuelData.volume = $scope.order.volume
  277 + $scope.fuelData.source = $scope.order.source
  278 + $scope.fuelData.status = $scope.order.status
  279 + $scope.fuelData.tierBreak = $scope.order.tierBreak
  280 + $scope.fuelData.total = $scope.order.total
  281 + $scope.fuelData.upliftDate = $scope.order.upliftDate
  282 + $scope.fuelData.companyId = $scope.selectedCompanyId;
  283 +
239 284  
240 285  
241 286 $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
242   - console.log('$scope.order', $scope.dispatchOrder);
  287 + // console.log('$scope.order', $scope.dispatchOrder);
243 288 fuelOrdersService.dispathFuelOrder($scope.dispatchOrder).then(function(result) {
244   - console.log('result', result);
  289 + // console.log('result', result);
245 290 $scope.showLoader = false;
246 291 $scope.order = {};
247 292 $('#demo-modal-4').css('display', '');
... ... @@ -253,25 +298,25 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
253 298  
254 299 }
255 300 $scope.updateStatus = function(row, status) {
256   - $scope.showLoader = true;
257   - $scope.fuelData = {};
258   - $scope.fuelData.aircraftName = row.aircraftName
259   - $scope.fuelData.companyName = row.companyName
260   - $scope.fuelData.departingDate = row.departingDate
261   - $scope.fuelData.fboCost = row.fboCost
262   - $scope.fuelData.id = row.id
263   - $scope.fuelData.invoiced = row.invoiced
264   - $scope.fuelData.priceQuote = row.priceQuote
265   - $scope.fuelData.volume = row.requestedVolume
266   - $scope.fuelData.source = row.source
267   - $scope.fuelData.status = status
268   - $scope.fuelData.tierBreak = row.tierBreak
269   - $scope.fuelData.total = row.total
270   - $scope.fuelData.upliftDate = row.upliftDate
  301 + $scope.showLoader = true;
  302 + $scope.fuelData = {};
  303 + $scope.fuelData.aircraftName = row.aircraftName
  304 + $scope.fuelData.companyName = row.companyName
  305 + $scope.fuelData.departingDate = row.departingDate
  306 + $scope.fuelData.fboCost = row.fboCost
  307 + $scope.fuelData.id = row.id
  308 + $scope.fuelData.invoiced = row.invoiced
  309 + $scope.fuelData.priceQuote = row.priceQuote
  310 + $scope.fuelData.volume = row.requestedVolume
  311 + $scope.fuelData.source = row.source
  312 + $scope.fuelData.status = status
  313 + $scope.fuelData.tierBreak = row.tierBreak
  314 + $scope.fuelData.total = row.total
  315 + $scope.fuelData.upliftDate = row.upliftDate
271 316  
272 317 $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
273 318 fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) {
274   - console.log('result', result);
  319 + // console.log('result', result);
275 320 $scope.showLoader = false;
276 321 $scope.editdata = {};
277 322 $('#demo-modal-5').css('display', '');
... ... @@ -284,27 +329,27 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
284 329 }
285 330  
286 331 $scope.updateData = function() {
287   - $scope.showLoader = true;
288   - $scope.fuelData = {};
289   - $scope.fuelData.aircraftName = $scope.editdata.aircraftName
290   - $scope.fuelData.companyName = $scope.editdata.companyName
291   - $scope.fuelData.departingDate = $scope.editdata.departingDate
292   - $scope.fuelData.fboCost = $scope.editdata.fboCost
293   - $scope.fuelData.id = $scope.editdata.id
294   - $scope.fuelData.invoiced = $scope.editdata.invoiced
295   - $scope.fuelData.priceQuote = $scope.editdata.priceQuote
296   - $scope.fuelData.volume = $scope.editdata.requestedVolume
297   - $scope.fuelData.source = $scope.editdata.source
298   - $scope.fuelData.status = $scope.editdata.status
299   - $scope.fuelData.tierBreak = $scope.editdata.tierBreak
300   - $scope.fuelData.total = $scope.editdata.total
301   - $scope.fuelData.upliftDate = $scope.editdata.upliftDate
  332 + $scope.showLoader = true;
  333 + $scope.fuelData = {};
  334 + $scope.fuelData.aircraftName = $scope.editdata.aircraftName
  335 + $scope.fuelData.companyName = $scope.editdata.companyName
  336 + $scope.fuelData.departingDate = $scope.editdata.departingDate
  337 + $scope.fuelData.fboCost = $scope.editdata.fboCost
  338 + $scope.fuelData.id = $scope.editdata.id
  339 + $scope.fuelData.invoiced = $scope.editdata.invoiced
  340 + $scope.fuelData.priceQuote = $scope.editdata.priceQuote
  341 + $scope.fuelData.volume = $scope.editdata.requestedVolume
  342 + $scope.fuelData.source = $scope.editdata.source
  343 + $scope.fuelData.status = $scope.editdata.status
  344 + $scope.fuelData.tierBreak = $scope.editdata.tierBreak
  345 + $scope.fuelData.total = $scope.editdata.total
  346 + $scope.fuelData.upliftDate = $scope.editdata.upliftDate
302 347  
303 348  
304 349  
305 350 $scope.dispatchOrder.fuelOrderList.push($scope.fuelData);
306 351 fuelOrdersService.updateFuelOrder($scope.dispatchOrder).then(function(result) {
307   - console.log('result', result);
  352 + // console.log('result', result);
308 353 $scope.showLoader = false;
309 354 $scope.editdata = {};
310 355 $('#demo-modal-5').css('display', '');
... ... @@ -316,8 +361,10 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
316 361 }
317 362  
318 363 $scope.getAircraft = function(company){
  364 +
319 365 $scope.selectedCompanyName = company;
320   - $scope.showLoader = true;
  366 + //$scope.showLoader = true;
  367 + // console.log("id",company)
321 368 for (var i = 0; i < $scope.companyList.length; i++) {
322 369 if ($scope.companyList[i].companyName == company) {
323 370 if($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null){
... ... @@ -344,17 +391,17 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
344 391 if ($scope.marginId != '') {
345 392 fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) {
346 393 $scope.tierList = tiers;
347   - $scope.showLoader = false;
  394 + // $scope.showLoader = false;
348 395 })
349 396 }else{
350   - $scope.showLoader = false;
  397 + // $scope.showLoader = false;
351 398 }
352 399 }
353 400 }
354 401  
355 402 }
356 403 $scope.setCost = function(cost){
357   - console.log(cost);
  404 + // console.log(cost);
358 405 if(cost != null) {
359 406 var obj =JSON.parse(cost);
360 407 $scope.order.fboCost = obj.cost;
... ... @@ -363,23 +410,198 @@ function fuelOrdersController($scope, $rootScope, $uibModal, $filter, $http, NgT
363 410 }
364 411  
365 412  
366   - $scope.cancelData = function() {
367   - $('#demo-modal-4').css('display', '');
368   - }
369   - $scope.canceleditdata = function() {
370   - $('#demo-modal-5').css('display', '');
371   -}
  413 + $scope.cancelData = function() {
  414 + $('#demo-modal-4').css('display', '');
  415 + }
  416 + $scope.canceleditdata = function() {
  417 + $('#demo-modal-5').css('display', '');
  418 + }
372 419  
373 420  
374 421  
375   - $scope.companyList = {};
  422 + $scope.companyList = {};
  423 +
  424 + fuelOrdersService.getAllCompanies().then(function(result) {
  425 + $scope.showLoader = true;
  426 + $scope.companyList = result;
  427 + $scope.showLoader = false;
  428 + })
  429 +
  430 + /*Add a company services API used from customersService */
  431 + getCompanyName();
  432 + function getCompanyName(){
  433 + CustomersService.getCompanyName().then(function(result) {
  434 + $scope.showLoader = true;
  435 + $scope.compNameList = result;
  436 + //console.log("kd",result)
  437 + $scope.showLoader = false;
  438 + })
  439 + }
  440 +
  441 + $scope.marginFilterOptions = [];
  442 + CustomersService.getJetMargin($scope.userProfileId).then(function(result) {
  443 + $scope.showLoader = true;
  444 + $scope.jetMarginList = result;
  445 + //console.log("jet margin",result,$scope.userProfileId)
  446 + $scope.marginFilterOptions.push({
  447 + 'id': '', 'title': 'Show All'
  448 + });
  449 + for (var i = 0; i < result.length; i++) {
  450 + $scope.marginFilterOptions.push({
  451 + 'id': result[i].id,
  452 + 'title': result[i].marginName
  453 + })
  454 + }
  455 + $scope.showLoader = false;
  456 + })
  457 +
  458 + CustomersService.getAvgMargin($scope.userProfileId).then(function(result) {
  459 + $scope.avgsMarginList = result;
  460 + // console.log('avgsMarginList',result)
  461 + })
  462 +
  463 + $scope.showCompanyError = false;
  464 + $scope.showMarginError = false;
  465 +
  466 + $scope.removeValidation = function(){
  467 + $scope.showCompanyError = false;
  468 + $('.companyNameInput').removeClass('customErrorInput');
  469 + if($scope.data.companyName == 'undefined' || $scope.data.companyName == '') {
  470 + $('.companyNameInput').addClass('customErrorInput');
  471 + $scope.showCompanyError = true;
  472 + }
  473 + }
376 474  
377   - fuelOrdersService.getAllCompanies().then(function(result) {
  475 + $scope.removeMarginValidation = function(){
  476 + $scope.showMarginError = false;
  477 + $('.marginSelectBox').removeClass('customErrorInput');
  478 + }
  479 +
  480 + getData();
  481 + function getData(){
  482 + $scope.showLoader = true;
  483 + CustomersService.getAircraftMake().then(function(result) {
  484 + $scope.aircraftMakeList = result;
  485 + $scope.showLoader = false;
  486 + })
  487 + }
  488 + var companyData;
  489 + $scope.addFirstData = function(sel, step){
378 490 $scope.showLoader = true;
379   - $scope.companyList = result;
380   - console.log(result)
  491 + if($scope.data.companyName == undefined){
  492 + $scope.showCompanyError = true;
  493 + $('.companyNameInput').addClass('customErrorInput');
  494 + }else if($scope.data.masterMargin == undefined){
  495 + $scope.showMarginError = true;
  496 + $('.marginSelectBox').addClass('customErrorInput');
  497 + }else{
  498 + $scope.aircraftDetails = [{
  499 + 'tail':'',
  500 + 'make': '',
  501 + 'model': '',
  502 + 'sizeId' : '',
  503 + 'marginId': $scope.data.masterMargin,
  504 + 'avgasMarginId': $scope.data.avgasMargin
  505 + }];
  506 +
  507 + $(sel).trigger('next.m.' + step);
  508 + getData();
  509 + }
381 510 $scope.showLoader = false;
382   - })
  511 + }
  512 + $scope.addNew = function(){
  513 + $scope.showLoader = true;
  514 + $scope.aircraftDetails.push({
  515 + 'tail':'',
  516 + 'make': '',
  517 + 'model': '',
  518 + 'sizeId' : '',
  519 + 'marginId': $scope.data.masterMargin,
  520 + 'avgasMarginId': $scope.data.avgasMargin
  521 + });
  522 + $scope.showLoader = false;
  523 + };
  524 +
  525 + $scope.aircraft = {};
  526 + $scope.getModal = function(makeId, index){
  527 + $scope.showLoader = true;
  528 + //console.log(makeId)
  529 + $scope.aircraft.make = makeId;
  530 + //var makeId = makeId;
  531 + CustomersService.getModal($scope.aircraft.make).then(function(result) {
  532 + $scope.showLoader = false;
  533 + $scope.aircraftDetails[index].aircraftModalList = result;
  534 + //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0];
  535 + })
  536 + }
  537 +
  538 + $scope.getSize = function(model, index){
  539 + $scope.showLoader = true;
  540 + CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) {
  541 + $scope.showLoader = false;
  542 + $scope.aircraftDetails[index].aircraftSizeList = result;
  543 + //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0];
  544 + })
  545 + }
  546 +
  547 + $scope.aircraftListData = {};
  548 + $scope.addData = [];
  549 + $scope.saveCompanyData = function(){
  550 + CustomersService.addCompany($scope.data).then(function(result) {
  551 + $scope.accountId = result;
  552 + $scope.aircraft.accountId = $scope.accountId;
  553 +
  554 + for(var i=0; i<$scope.aircraftDetails.length;i++){
  555 + $scope.addData.push({
  556 + 'tail': $scope.aircraftDetails[i].tail,
  557 + 'make': $scope.aircraftDetails[i].make,
  558 + 'model': $scope.aircraftDetails[i].model,
  559 + 'sizeId' : $scope.aircraftDetails[i].sizeId,
  560 + 'marginId': $scope.aircraftDetails[i].marginId,
  561 + 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId
  562 + });
  563 + }
  564 + $scope.aircraftListData.aircraftList = $scope.addData;
  565 + $scope.aircraftListData.accountId = $scope.aircraft.accountId;
  566 +
  567 + if($scope.aircraftListData.aircraftList[0].tail == "" || $scope.aircraftListData.aircraftList[0].make == null || $scope.aircraftListData.aircraftList[0].model == null){
  568 + $scope.aircraftListData.aircraftList = [];
  569 + }
  570 +
  571 + CustomersService.addAircraft($scope.aircraftListData).then(function(result) {
  572 +
  573 + if(result != null && result.success){
  574 + toastr.success(''+result.success+'', {
  575 + closeButton: true
  576 + })
  577 + $('#demo-modal-3').modal('hide');
  578 + getAllCompanies();
  579 + }else{
  580 + toastr.error(''+result.statusText+'', {
  581 + closeButton: true
  582 + })
  583 + }
  584 + });
  585 +
  586 + })
  587 +
  588 +
  589 + }
  590 +
  591 + $scope.checkJetWithTail = function(tail, index){
  592 +
  593 + //console.log("tail==============",tail, index)
  594 + ViewCompanyService.checkJetType(tail).then(function(result) {
  595 + //console.log("result",result)
  596 + if(result.jetA == "true"){
  597 + $scope.jetShow[index] = false;
  598 + $scope.marginShow[index] = true;
  599 + }else{
  600 + $scope.jetShow[index] = true;
  601 + $scope.marginShow[index] = false;
  602 + }
  603 + })
  604 + }
383 605  
384 606 $scope.sourceList = [{source:"Direct Jet-A"},{source:"Direct AVGAS 100LL"}];
385 607  
... ...
app/partials/fuelOrders/fuelOrders.html
... ... @@ -193,7 +193,9 @@
193 193 <label class="new-input-label"><b>Company Name *</b></label>
194 194 </div>
195 195 <div class="pull-left" style="margin-left: 15px;">
196   - <input type="text" ng-model="data.companyName" class="form-control companyNameInput" ng-keyup="removeValidation()" placeholder="" required>
  196 + <!-- <input type="text" ng-model="data.companyName" class="form-control companyNameInput" ng-keyup="removeValidation()" placeholder="" required> -->
  197 + <input type="text" ng-keyup="removeValidation()" ng-model="data.companyName" uib-typeahead="company.companyName for company in compNameList | filter:$viewValue | limitTo:8" class="form-control companyNameInput">
  198 +
197 199 <label class="customErrorMessage" ng-show="showCompanyError">This field is required.</label>
198 200 </div>
199 201 <div class="clearfix"></div>
... ... @@ -440,36 +442,48 @@
440 442 <input type="checkbox" ng-model="aircraftData.selected"/>
441 443 </td> -->
442 444 <td style="width: 15%">
443   - <input type="text" class="form-control" ng-model="aircraftData.tail" required/>
  445 + <input type="text" class="form-control" ng-model="aircraftData.tail" ng-blur="checkJetWithTail(aircraftData.tail, $index)" required/>
444 446 </td>
445 447 <td style="width: 17%">
446 448 <select class="form-control" ng-model="aircraftData.make" ng-change="getModal(aircraftData.make, $index)">
447   - <option ng-repeat="make in aircraftMakeList">{{make}}</option>
  449 + <option ng-repeat="make in aircraftMakeList | orderBy">{{make}}</option>
448 450 <option value="" disabled>Select...</option>
449 451 </select>
450 452 </td>
451 453 <td style="width: 17%">
452 454 <select class="form-control" ng-model="aircraftData.model" ng-change="getSize(aircraftData.model, $index)">
453   - <option ng-repeat="model in aircraftData.aircraftModalList">{{model}}</option>
  455 + <option ng-repeat="model in aircraftData.aircraftModalList | orderBy">{{model}}</option>
454 456 <option value="" disabled>Select...</option>
455 457 </select>
456 458 </td>
457 459 <td style="width: 17%">
458   - <select class="form-control" ng-model="aircraftData.sizeId" ng-options="size.aircraftSize.id as size.aircraftSize.size for size in aircraftData.aircraftSizeList">
  460 + <!-- <select class="form-control" ng-model="aircraftData.sizeId" ng-options="size.aircraftSize.id as size.aircraftSize.size for size in aircraftData.aircraftSizeList">
459 461 <option value="" disabled>Select...</option>
  462 + </select> -->
  463 + <select class="form-control" ng-model="aircraftData.sizeId">
  464 + <option value="" disabled>Select</option>
  465 + <option ng-repeat="size in aircraftData.aircraftSizeList" value="{{size.aircraftSize.id}}">{{size.aircraftSize.size}}</option>
460 466 </select>
461 467 <!-- <select class="form-control" ng-model="aircraftData.size">
462 468 <option ng-repeat="size in aircraftData.aircraftSizeList">{{size}}</option>
463 469 </select> -->
464 470 </td>
465 471 <td style="width: 17%">
466   - <select class="form-control" ng-model="aircraftData.marginId" ng-options="margin.id as margin.marginName for margin in jetMarginList">
  472 + <!-- <select class="form-control" ng-model="aircraftData.marginId" ng-options="margin.id as margin.marginName for margin in jetMarginList">
467 473 <option value="" disabled>Select...</option>
  474 + </select> -->
  475 + <select class="form-control" ng-model="aircraftData.marginId" ng-disabled="jetShow[$index]">
  476 + <option value="" disabled>Select</option>
  477 + <option ng-repeat="margin in jetMarginList" value="{{margin.id}}">{{margin.marginName}}</option>
468 478 </select>
469 479 </td>
470 480 <td style="width: 17%">
471   - <select class="form-control marginSelectBox" ng-model="aircraftData.avgasMarginId" ng-options="avgs.id as avgs.marginName for avgs in avgsMarginList">
  481 + <!-- <select class="form-control marginSelectBox" ng-model="aircraftData.avgasMarginId" ng-options="avgs.id as avgs.marginName for avgs in avgsMarginList">
472 482 <option value="" disabled>Select...</option>
  483 + </select> -->
  484 + <select class="form-control" ng-model="aircraftData.avgasMarginId" ng-disabled="marginShow[$index]">
  485 + <option value="" disabled>Select</option>
  486 + <option ng-repeat="avgs in avgsMarginList" value="{{avgs.id}}">{{avgs.marginName}}</option>
473 487 </select>
474 488 </td>
475 489 </tr>
... ... @@ -536,7 +550,7 @@
536 550 <label class="new-input-label"><b>Fueling Date</b></label>
537 551 </div>
538 552 <div class="pull-left" style="width: calc(100% - 110px);">
539   - <input type="date" ng-model="order.upliftDate" class="form-control" placeholder="">
  553 + <input type="type" ng-model="order.upliftDate" class="form-control" placeholder="Select Date" datepicker />
540 554 <!--<md-datepicker ng-model="myDate" md-placeholder="Enter date"></md-datepicker>-->
541 555 </div>
542 556 <div class="clearfix"></div>
... ... @@ -570,9 +584,10 @@
570 584 <div class="col-md-6">
571 585 <div class="pull-left" style="width: 110px;">
572 586 <label class="new-input-label"><b>Invoiced</b></label>
  587 + <span style="margin-top: 6px; margin-right: 3px; float: right;">$</span>
573 588 </div>
574 589 <div class="pull-left" style="width: calc(100% - 110px);">
575   - <input type="text" ng-model="order.invoiced" ng-keyup="addTotal(order.invoiced,'i')" class="form-control" placeholder="">
  590 + <input type="text" ng-model="order.invoiced" ng-keyup="addTotal(order.invoiced,'i')" class="form-control" placeholder="0.0000" valid-number />
576 591 </div>
577 592 <div class="clearfix"></div>
578 593 </div>
... ... @@ -600,9 +615,10 @@
600 615 <div class="col-md-6">
601 616 <div class="pull-left" style="width: 110px;">
602 617 <label class="new-input-label"><b>Total</b></label>
  618 + <span style="margin-top: 6px; margin-right: 3px; float: right;">$</span>
603 619 </div>
604 620 <div class="pull-left" style="width: calc(100% - 110px);">
605   - <input type="text" disabled ng-model="order.total" class="form-control" placeholder="0.0" value="{{order.volume * order.invoiced}}">
  621 + <input type="text" disabled ng-model="order.total" class="form-control" placeholder="0.0000" value="{{order.volume * order.invoiced}}" valid-number />
606 622  
607 623 </div>
608 624 <div class="clearfix"></div>
... ... @@ -632,7 +648,7 @@
632 648 <div class="pull-left" style="width: calc(100% - 110px);">
633 649 <select ui-select2 style="width: 100%;" ng-model="order.priceQuote" ng-change="setCost(order.priceQuote)">
634 650 <option value="" selected disabled>Select Price Quote</option>
635   - <option ng-repeat="margin in marginList" value="{{margin}}">${{margin.papTotal}} {{margin.productName}}</option>
  651 + <option ng-repeat="margin in marginList" value="{{margin}}">${{margin.papTotal | number : 4}} {{margin.productName}}</option>
636 652 </select>
637 653 </div>
638 654 <div class="clearfix"></div>
... ... @@ -663,9 +679,10 @@
663 679 <div class="col-md-6">
664 680 <div class="pull-left" style="width: 110px;">
665 681 <label class="new-input-label"><b>FBO Cost</b></label>
  682 + <span style="margin-top: 6px; margin-right: 3px; float: right;">$</span>
666 683 </div>
667 684 <div class="pull-left" style="width: calc(100% - 110px);">
668   - <input type="text" disabled ng-model="order.fboCost" class="form-control" placeholder="">
  685 + <input type="text" disabled ng-model="order.fboCost" class="form-control" placeholder="0.0000" valid-number />
669 686 </div>
670 687 <div class="clearfix"></div>
671 688 </div>
... ...
app/partials/main/main.controller.js
... ... @@ -3,15 +3,51 @@
3 3 'use strict'
4 4  
5 5 angular.module('acufuel')
6   - .controller('MainController', [ '$scope', '$filter','$rootScope','$state', '$window', MainController]);
  6 + .controller('MainController', [ '$scope', '$filter','$rootScope','$state', '$window', '$interval', MainController]);
7 7  
8   - function MainController($scope, $filter, $rootScope,$state, $window) {
  8 + function MainController($scope, $filter, $rootScope,$state, $window, $interval) {
9 9  
10 10 $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName'));
11 11  
  12 +
12 13 $scope.testFunction = function(){
13 14 $scope.currentUserName = JSON.parse(localStorage.getItem('currentUserName'));
14 15 }
  16 +
  17 + /**
  18 + Automatic logout session
  19 + **/
  20 +
  21 + var resetTime;
  22 + /*function warning(){
  23 + //setTimeout(function(){
  24 + $('.warning-message').delay(5000).css('display', 'block');
  25 + //}, 5000);
  26 + }*/
  27 +
  28 + resetTime = setInterval(function(){
  29 + // $('.warning-message').delay(5000).css('display', 'block');
  30 + //console.log('out');
  31 + localStorage.clear();
  32 + $state.go('login');
  33 + }, 600000);
  34 +
  35 +
  36 + $(document).mousemove(function(event){
  37 + clearInterval(resetTime);
  38 + //$('.warning-message').delay(5000).css('display', 'none');
  39 + // warning();
  40 + //console.log('restart');
  41 + resetTime = setInterval(function(){
  42 + //console.log('out');
  43 + //warning();
  44 + localStorage.clear();
  45 + $state.go('login');
  46 + }, 600000);
  47 + })
  48 +
  49 +
  50 +
15 51  
16 52 // Flight Tracking page code
17 53  
... ... @@ -33,8 +69,14 @@
33 69 }
34 70 }*/
35 71  
  72 + // Set timeout variables.
36 73  
37 74 }
  75 + //var timoutWarning = 840000; // Display warning in 14 Mins.
  76 + //var timoutNow = 900000; // Timeout in 15 mins.
  77 +
  78 +
  79 +
38 80  
39 81 })();
40 82  
... ...
app/partials/main/main.html
  1 +
1 2 <nav class="navbar navbar-inverse" role="navigation">
2 3 <div class="container">
3 4 <!-- Brand and toggle get grouped for better mobile display -->
... ... @@ -203,3 +204,9 @@
203 204 </div>
204 205 <!-- /container -->
205 206 </div>
  207 +
  208 +
  209 +<!--automatic logout session-->
  210 +<!-- <div class="alert alert-warning warning-message" style="display: none; z-index: 99999; position: fixed; top: 50px; right: 50px;">
  211 + <strong>Warning!</strong> Indicates a warning that might need attention.
  212 +</div> -->
206 213 \ No newline at end of file
... ...