diff --git a/app/partials/customers/customers.controller.js b/app/partials/customers/customers.controller.js index 1b90afa..34314b1 100644 --- a/app/partials/customers/customers.controller.js +++ b/app/partials/customers/customers.controller.js @@ -1,529 +1,482 @@ 'use strict'; - //Load controller - angular.module('acufuel') - .controller('customersController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', '$state', 'CustomersService', 'ViewCompanyService', 'NgTableParams','fuelOrdersService', customersController]); - - function customersController($scope, $rootScope, $uibModal, $filter, $http, $state, CustomersService, ViewCompanyService, NgTableParams,fuelOrdersService) { - $(document).ready(function() { - // $('#example').DataTable(); - }); - $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')) - $scope.reset2 = function(){ - $("input").val(""); - $scope.removeMarginValidation(); - } - - - $scope.data = {}; - $scope.aircraft = {}; - $scope.data.activate = true; - $scope.showLoader = true; - $scope.jetShow = []; - $scope.marginShow = []; - - $scope.jetShow[0] = true; - $scope.marginShow[0] = true; - $scope.dispatchOrder = {}; - $scope.dispatchOrder.fuelOrderList = []; - $scope.statusFilterOptions = []; - $scope.companyList = {}; - $scope.statusFilterOptions.push({ - 'id': '', 'title': 'Show All' - },{ - 'id': 'pending', 'title': 'Pending' - },{ - 'id': 'invoiced', 'title': 'Invoiced' - },{ - 'id': 'paid', 'title': 'Paid' - },{ - 'id': 'cancelled', 'title': 'Cancelled' - },{ - 'id': 'archived', 'title': 'Archived' - } - - ); - - getAllCompanies(); - - /*function getAllCompanies(){ - CustomersService.getAllCompanies().then(function(result) { - $scope.companyList = result; - for(var i=0; i<$scope.companyList.length; i++){ - $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; - } - }) - - }*/ - - $scope.statusFilter = [ - {id: "", title: "Show All"}, - {id: "true", title: "Active"}, - {id: "false", title: "Inactive"} - ] - - function getAllCompanies(){ - CustomersService.getAllCompanies().then(function(result) { - //console.log('log', result); - $scope.companyList = result; - for (var i = 0; i < $scope.companyList.length; i++) { - if ($scope.companyList[i].companyContact != null) { - if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) { - $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber; - } - } - if ($scope.companyList[i].primaryContact != null) { - if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) { - $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName; - } - } - if ($scope.companyList[i].margin != null) { - if ($scope.companyList[i].margin.marginName != null) { - $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; - } - } - } - $scope.displayCompanyList = new NgTableParams({ - page: 1, - count: 10, - }, { - data: $scope.companyList - }); - $scope.showLoader = false; - }) - } - - $scope.editMargin = function(customer){ - //console.log('customer', customer); - $scope.showLoader = true; - event.stopPropagation(); - - var companyMargin = "companyName=" + customer.companyName + "&masterMargin=" + customer.masterMargin - + "&addressOne=" + customer.addressOne + "&addressTwo=" + customer.addressTwo + "&city=" + customer.city + "&state=" - + customer.state + "&country=" + customer.country + "&zipcode=" + customer.zipcode + "&internalNote=" - + customer.internalNote + "&certificateType=" + customer.certificateType + "&baseTenant=" + customer.baseTenant - + "&fuelerlinxCustomer=" + customer.fuelerlinxCustomer + "&contractFuelVendor=" + customer.contractFuelVendor - + "&activate=" + customer.activate + "&baseIcao=" + customer.baseIcao + "&companyId=" + customer.id; - - ViewCompanyService.updateCompany(companyMargin).then(function(result) { - if(result != null && result.success){ - $scope.showLoader = false; - toastr.success(''+result.success+'', { - closeButton: true - }) - getAllCompanies(); - }else{ - $scope.showLoader = false; - toastr.error(''+result.statusText+'', { - closeButton: true - }) - } - }) - } - - getData(); - function getData(){ - $scope.showLoader = true; - CustomersService.getAircraftMake().then(function(result) { - $scope.aircraftMakeList = result; - $scope.showLoader = false; - }) - } - - - // CustomersService.getMargin().then(function(result) { - // $scope.marginList = result; - // }) - $scope.marginFilterOptions = []; - CustomersService.getJetMargin($scope.userProfileId).then(function(result) { - $scope.showLoader = true; - $scope.jetMarginList = result; - //console.log("jet margin",result,$scope.userProfileId) - $scope.marginFilterOptions.push({ - 'id': '', 'title': 'Show All' - }); - for (var i = 0; i < result.length; i++) { - $scope.marginFilterOptions.push({ - 'id': result[i].id, - 'title': result[i].marginName - }) - } - $scope.showLoader = false; - }) - - CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { - $scope.avgsMarginList = result; - // console.log('avgsMarginList',result) - }) - - - $scope.showCompanyError = false; - $scope.showMarginError = false; - - $scope.removeValidation = function(){ - $scope.showCompanyError = false; - $('.companyNameInput').removeClass('customErrorInput'); - if($scope.data.companyName == 'undefined' || $scope.data.companyName == '') { - $('.companyNameInput').addClass('customErrorInput'); - $scope.showCompanyError = true; - } - } - - $scope.removeMarginValidation = function(){ - $scope.showMarginError = false; - $('.marginSelectBox').removeClass('customErrorInput'); - } - - var companyData; - $scope.addFirstData = function(sel, step){ - $scope.showLoader = true; - if($scope.data.companyName == undefined){ - $scope.showCompanyError = true; - $('.companyNameInput').addClass('customErrorInput'); - }else if($scope.data.masterMargin == undefined){ - $scope.showMarginError = true; - $('.marginSelectBox').addClass('customErrorInput'); - }else{ - $scope.aircraftDetails = [{ - 'tail':'', - 'make': '', - 'model': '', - 'sizeId' : '', - 'marginId': $scope.data.masterMargin, - 'avgasMarginId': $scope.data.avgasMargin - }]; - - $(sel).trigger('next.m.' + step); - getData(); - } - $scope.showLoader = false; - } - $scope.addNew = function(){ - $scope.showLoader = true; - $scope.aircraftDetails.push({ - 'tail':'', - 'make': '', - 'model': '', - 'sizeId' : '', - 'marginId': $scope.data.masterMargin, - 'avgasMarginId': $scope.data.avgasMargin - }); - $scope.showLoader = false; - }; - - $scope.getModal = function(makeId, index){ - $scope.showLoader = true; - //console.log(makeId) - $scope.aircraft.make = makeId; - //var makeId = makeId; - CustomersService.getModal($scope.aircraft.make).then(function(result) { - $scope.showLoader = false; - $scope.aircraftDetails[index].aircraftModalList = result; - //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; - }) - } - - $scope.getSize = function(model, index){ - $scope.showLoader = true; - CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { - $scope.showLoader = false; - $scope.aircraftDetails[index].aircraftSizeList = result; - - }) - } - - - - $scope.aircraftListData = {}; - $scope.addData = []; - $scope.saveCompanyData = function(){ - CustomersService.addCompany($scope.data).then(function(result) { - $scope.accountId = result; - $scope.aircraft.accountId = $scope.accountId; - - for(var i=0; i<$scope.aircraftDetails.length;i++){ - $scope.addData.push({ - 'tail': $scope.aircraftDetails[i].tail, - 'make': $scope.aircraftDetails[i].make, - 'model': $scope.aircraftDetails[i].model, - 'sizeId' : $scope.aircraftDetails[i].sizeId, - 'marginId': $scope.aircraftDetails[i].marginId, - 'avgasMarginId': $scope.aircraftDetails[i].avgasMarginId - }); - } - $scope.aircraftListData.aircraftList = $scope.addData; - $scope.aircraftListData.accountId = $scope.aircraft.accountId; - - if($scope.aircraftListData.aircraftList[0].tail == "" || $scope.aircraftListData.aircraftList[0].make == null || $scope.aircraftListData.aircraftList[0].model == null){ - $scope.aircraftListData.aircraftList = []; - } - - CustomersService.addAircraft($scope.aircraftListData).then(function(result) { - - if(result != null && result.success){ - toastr.success(''+result.success+'', { - closeButton: true - }) - $('#demo-modal-3').modal('hide'); - getAllCompanies(); - }else{ - toastr.error(''+result.statusText+'', { - closeButton: true - }) - } - }); - - }) - - - } - - /*add a fuel order*/ - - - $scope.getOrders = function() { - fuelOrdersService.getOrders().then(function(result) { - - $scope.orderdata = result; - for(var i=0;i<$scope.orderdata.length;i++){ - $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); - - // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear() - var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear() - // str = str.slice(4,16) - $scope.orderdata[i].upliftDateString = str - // console.log(str); - - } - - $scope.displayFuelOrderList = new NgTableParams({ - page: 1, - count: 10, - }, { - data: $scope.orderdata - }); - $(document).ready(function(){ - var myselect = document.getElementsByClassName('colorfulSelectbox'); - - for (var i = 0; i < myselect.length; i++) { - var colourIndex = $(myselect[i]).prop('selectedIndex'); - colourIndex = colourIndex + 1; - // console.log(colourIndex); - var getColor = $('.colorfulSelectbox option:nth-child('+colourIndex+')').css('color'); - $(myselect[i]).css('background-color', getColor); - // console.log('colour', getColor); - myselect[i].blur(); - } - - }) - - }) - } - - $scope.getOrders(); - - $scope.addFuelData = function() { - $scope.showLoader = true; - - if ($scope.order.priceQuote === null || $scope.order.priceQuote == '') { - // console.log("valid"); - $scope.showLoader = false; - toastr.error('Please select Company and Price Quote.', { +//Load controller +angular.module('acufuel') + .controller('customersController', [ '$scope', '$rootScope', '$uibModal', '$filter', '$http', '$state', 'CustomersService', 'ViewCompanyService', 'NgTableParams', 'fuelOrdersService', 'enterFuelOrderService', customersController ]); + +function customersController($scope, $rootScope, $uibModal, $filter, $http, $state, CustomersService, ViewCompanyService, NgTableParams, fuelOrdersService, enterFuelOrderService) { + $(document).ready(function() { + // $('#example').DataTable(); + }); + $scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')) + $scope.reset2 = function() { + $("input").val(""); + $scope.removeMarginValidation(); + } + + $scope.order = {}; + $scope.order.upliftDate = ''; + $scope.data = {}; + $scope.aircraft = {}; + $scope.data.activate = true; + $scope.showLoader = true; + $scope.jetShow = []; + $scope.marginShow = []; + + $scope.jetShow[0] = true; + $scope.marginShow[0] = true; + $scope.dispatchOrder = {}; + $scope.dispatchOrder.fuelOrderList = []; + $scope.statusFilterOptions = []; + $scope.companyList = {}; + $scope.statusFilterOptions.push({ + 'id' : '', + 'title' : 'Show All' + }, { + 'id' : 'pending', + 'title' : 'Pending' + }, { + 'id' : 'invoiced', + 'title' : 'Invoiced' + }, { + 'id' : 'paid', + 'title' : 'Paid' + }, { + 'id' : 'cancelled', + 'title' : 'Cancelled' + }, { + 'id' : 'archived', + 'title' : 'Archived' + } + + ); + + getAllCompanies(); + + /*function getAllCompanies(){ + CustomersService.getAllCompanies().then(function(result) { + $scope.companyList = result; + for(var i=0; i<$scope.companyList.length; i++){ + $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; + } + }) + + }*/ + + $scope.statusFilter = [ + { + id : "", + title : "Show All" + }, + { + id : "true", + title : "Active" + }, + { + id : "false", + title : "Inactive" + } + ] + + function getAllCompanies() { + CustomersService.getAllCompanies().then(function(result) { + //console.log('log', result); + $scope.companyList = result; + for (var i = 0; i < $scope.companyList.length; i++) { + if ($scope.companyList[i].companyContact != null) { + if ($scope.companyList[i].companyContact.contactNumber != null || $scope.companyList[i].companyContact.contactNumber != undefined) { + $scope.companyList[i].newContactNumber = $scope.companyList[i].companyContact.contactNumber; + } + } + if ($scope.companyList[i].primaryContact != null) { + if ($scope.companyList[i].primaryContact.firstName != null && $scope.companyList[i].primaryContact.lastName != null) { + $scope.companyList[i].primaryContactName = $scope.companyList[i].primaryContact.firstName + ' ' + $scope.companyList[i].primaryContact.lastName; + } + } + if ($scope.companyList[i].margin != null) { + if ($scope.companyList[i].margin.marginName != null) { + $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; + } + } + } + $scope.displayCompanyList = new NgTableParams({ + page : 1, + count : 10, + }, { + data : $scope.companyList + }); + $scope.showLoader = false; + }) + } + + $scope.editMargin = function(customer) { + //console.log('customer', customer); + $scope.showLoader = true; + event.stopPropagation(); + + var companyMargin = "companyName=" + customer.companyName + "&masterMargin=" + customer.masterMargin + + "&addressOne=" + customer.addressOne + "&addressTwo=" + customer.addressTwo + "&city=" + customer.city + "&state=" + + customer.state + "&country=" + customer.country + "&zipcode=" + customer.zipcode + "&internalNote=" + + customer.internalNote + "&certificateType=" + customer.certificateType + "&baseTenant=" + customer.baseTenant + + "&fuelerlinxCustomer=" + customer.fuelerlinxCustomer + "&contractFuelVendor=" + customer.contractFuelVendor + + "&activate=" + customer.activate + "&baseIcao=" + customer.baseIcao + "&companyId=" + customer.id; + + ViewCompanyService.updateCompany(companyMargin).then(function(result) { + if (result != null && result.success) { + $scope.showLoader = false; + toastr.success('' + result.success + '', { + closeButton : true + }) + getAllCompanies(); + } else { + $scope.showLoader = false; + toastr.error('' + result.statusText + '', { + closeButton : true + }) + } + }) + } + + getData(); + function getData() { + $scope.showLoader = true; + CustomersService.getAircraftMake().then(function(result) { + $scope.aircraftMakeList = result; + $scope.showLoader = false; + }) + } + // CustomersService.getMargin().then(function(result) { + // $scope.marginList = result; + // }) + $scope.marginFilterOptions = []; + CustomersService.getJetMargin($scope.userProfileId).then(function(result) { + $scope.showLoader = true; + $scope.jetMarginList = result; + //console.log("jet margin",result,$scope.userProfileId) + $scope.marginFilterOptions.push({ + 'id' : '', + 'title' : 'Show All' + }); + for (var i = 0; i < result.length; i++) { + $scope.marginFilterOptions.push({ + 'id' : result[i].id, + 'title' : result[i].marginName + }) + } + $scope.showLoader = false; + }) + + CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { + $scope.avgsMarginList = result; + // console.log('avgsMarginList',result) + }) + + + $scope.showCompanyError = false; + $scope.showMarginError = false; + + $scope.removeValidation = function() { + $scope.showCompanyError = false; + $('.companyNameInput').removeClass('customErrorInput'); + if ($scope.data.companyName == 'undefined' || $scope.data.companyName == '') { + $('.companyNameInput').addClass('customErrorInput'); + $scope.showCompanyError = true; + } + } + + $scope.removeMarginValidation = function() { + $scope.showMarginError = false; + $('.marginSelectBox').removeClass('customErrorInput'); + } + + var companyData; + $scope.addFirstData = function(sel, step) { + $scope.showLoader = true; + if ($scope.data.companyName == undefined) { + $scope.showCompanyError = true; + $('.companyNameInput').addClass('customErrorInput'); + } else if ($scope.data.masterMargin == undefined) { + $scope.showMarginError = true; + $('.marginSelectBox').addClass('customErrorInput'); + } else { + $scope.aircraftDetails = [ { + 'tail' : '', + 'make' : '', + 'model' : '', + 'sizeId' : '', + 'marginId' : $scope.data.masterMargin, + 'avgasMarginId' : $scope.data.avgasMargin + } ]; + + $(sel).trigger('next.m.' + step); + getData(); + } + $scope.showLoader = false; + } + $scope.addNew = function() { + $scope.showLoader = true; + $scope.aircraftDetails.push({ + 'tail' : '', + 'make' : '', + 'model' : '', + 'sizeId' : '', + 'marginId' : $scope.data.masterMargin, + 'avgasMarginId' : $scope.data.avgasMargin + }); + $scope.showLoader = false; + }; + + $scope.getModal = function(makeId, index) { + $scope.showLoader = true; + //console.log(makeId) + $scope.aircraft.make = makeId; + //var makeId = makeId; + CustomersService.getModal($scope.aircraft.make).then(function(result) { + $scope.showLoader = false; + $scope.aircraftDetails[index].aircraftModalList = result; + //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; + }) + } + + $scope.getSize = function(model, index) { + $scope.showLoader = true; + CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { + $scope.showLoader = false; + $scope.aircraftDetails[index].aircraftSizeList = result; + }) + } + + $scope.aircraftListData = {}; + $scope.addData = []; + $scope.saveCompanyData = function() { + CustomersService.addCompany($scope.data).then(function(result) { + $scope.accountId = result; + $scope.aircraft.accountId = $scope.accountId; + + for (var i = 0; i < $scope.aircraftDetails.length; i++) { + $scope.addData.push({ + 'tail' : $scope.aircraftDetails[i].tail, + 'make' : $scope.aircraftDetails[i].make, + 'model' : $scope.aircraftDetails[i].model, + 'sizeId' : $scope.aircraftDetails[i].sizeId, + 'marginId' : $scope.aircraftDetails[i].marginId, + 'avgasMarginId' : $scope.aircraftDetails[i].avgasMarginId + }); + } + $scope.aircraftListData.aircraftList = $scope.addData; + $scope.aircraftListData.accountId = $scope.aircraft.accountId; + + if ($scope.aircraftListData.aircraftList[0].tail == "" || $scope.aircraftListData.aircraftList[0].make == null || $scope.aircraftListData.aircraftList[0].model == null) { + $scope.aircraftListData.aircraftList = []; + } + + CustomersService.addAircraft($scope.aircraftListData).then(function(result) { + + if (result != null && result.success) { + toastr.success('' + result.success + '', { + closeButton : true + }) + $('#demo-modal-3').modal('hide'); + getAllCompanies(); + } else { + toastr.error('' + result.statusText + '', { + closeButton : true + }) + } + }); + + }) + } + + /*add a fuel order*/ + $scope.getOrders = function() { + fuelOrdersService.getOrders().then(function(result) { + + $scope.orderdata = result; + for (var i = 0; i < $scope.orderdata.length; i++) { + $scope.orderdata[i].upliftDateS = new Date($scope.orderdata[i].upliftDate); + + // var str = "" + $scope.orderdata[i].upliftDateS.getDate() + "/" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getFullYear() + var str = "" + ($scope.orderdata[i].upliftDateS.getMonth() + 1) + "/" + $scope.orderdata[i].upliftDateS.getDate() + "/" + $scope.orderdata[i].upliftDateS.getFullYear() + // str = str.slice(4,16) + $scope.orderdata[i].upliftDateString = str + // console.log(str); + + } + + $scope.displayFuelOrderList = new NgTableParams({ + page : 1, + count : 10, + }, { + data : $scope.orderdata + }); + $(document).ready(function() { + var myselect = document.getElementsByClassName('colorfulSelectbox'); + + for (var i = 0; i < myselect.length; i++) { + var colourIndex = $(myselect[i]).prop('selectedIndex'); + colourIndex = colourIndex + 1; + // console.log(colourIndex); + var getColor = $('.colorfulSelectbox option:nth-child(' + colourIndex + ')').css('color'); + $(myselect[i]).css('background-color', getColor); + // console.log('colour', getColor); + myselect[i].blur(); + } + + }) + + }) + } + + $scope.getOrders(); + $scope.tiervalue=function(){ + $scope.order.tierBreak=$scope.selectedTier.minTierBreak+'-'+$scope.selectedTier.maxTierBreak; + } + + $scope.setCost = function(cost){ + if(cost != null) { + var obj =JSON.parse(cost); + $scope.order.fboCost = obj.cost; + } + } + + $scope.cancelOrder = function() { + $scope.order = {}; + } + + $scope.dispatchFuel = function(){ + $scope.showLoader = true; + $scope.order.companyId = $scope.selectedCompanyId; + if ($scope.order.upliftDate != '') { + var currentDate = new Date(); + var hours = currentDate.getHours(); + var min = currentDate.getMinutes(); + var sec = currentDate.getSeconds(); + $scope.order.upliftDate = $scope.order.upliftDate + ' ' + hours + ':' + min + ':' + sec; + $scope.order.upliftDate = new Date($scope.order.upliftDate); + $scope.order.upliftDate = $scope.order.upliftDate.getTime(); + } + $scope.order.status = 'pending'; + var obj =JSON.parse($scope.order.priceQuote); + $scope.order.priceQuote = obj.papMargin; + var aircraftObj =JSON.parse($scope.order.aircraftName); + $scope.order.aircraftName = aircraftObj.tail; + $scope.order.make = aircraftObj.make; + $scope.order.model = aircraftObj.model; + $scope.dispatchOrder.fuelOrderList.push($scope.order); + enterFuelOrderService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { + $scope.showLoader = false; + $scope.order = {}; + $('#demo-modal-4').css('display', ''); + toastr.success('Fuel Order Dispatched Successfully', { closeButton: true }) - }else{ - - if ($scope.order.upliftDate != '') { - $scope.order.upliftDate = new Date($scope.order.upliftDate); - $scope.order.upliftDate = $scope.order.upliftDate.getTime(); - } - if ($scope.order.departingDate != '') { - $scope.order.departingDate = new Date($scope.order.departingDate); - $scope.order.departingDate = $scope.order.departingDate.getTime(); - } - // console.log($scope.order.quotePrice); - var obj =JSON.parse($scope.order.priceQuote); - // console.log('obj.papMargin',obj.papMargin); - $scope.order.priceQuote = obj.papMargin; - - $scope.fuelData = {}; - $scope.fuelData.aircraftName = $scope.order.aircraftName - $scope.fuelData.companyName = $scope.order.companyName - $scope.fuelData.departingDate = $scope.order.departingDate - $scope.fuelData.fboCost = $scope.order.fboCost - $scope.fuelData.id = $scope.order.id - $scope.fuelData.invoiced = $scope.order.invoiced - $scope.fuelData.priceQuote = $scope.order.priceQuote - $scope.fuelData.volume = $scope.order.volume - $scope.fuelData.source = $scope.order.source - $scope.fuelData.status = $scope.order.status - $scope.fuelData.tierBreak = $scope.order.tierBreak - $scope.fuelData.total = $scope.order.total - $scope.fuelData.upliftDate = $scope.order.upliftDate - $scope.fuelData.companyId = $scope.selectedCompanyId; - - - - $scope.dispatchOrder.fuelOrderList.push($scope.fuelData); - // console.log('$scope.order', $scope.dispatchOrder); - fuelOrdersService.dispathFuelOrder($scope.dispatchOrder).then(function(result) { - //console.log("fuel data---",$scope.fuelData) - //console.log("oder data",$scope.dispatchOrder) - //console.log('result', result); - $scope.showLoader = false; - $scope.order = {}; - $('#demo-modal-4').css('display', ''); - $scope.getOrders(); - toastr.success('Fuel Order Dispatched Successfully', { - closeButton: true - }) - }) - - } - } - - $scope.addTotal = function(value, valueOf){ - if(valueOf == 'v'){ - $scope.order.total = value * $scope.order.invoiced - }else if(valueOf == 'i'){ - $scope.order.total = $scope.order.volume * value - } - } - - $scope.getAircraft = function(company){ - - $scope.selectedCompanyName = company; - //$scope.showLoader = true; - // console.log("id",company) - for (var i = 0; i < $scope.companyList.length; i++) { - if ($scope.companyList[i].companyName == company) { - if($scope.companyList[i].margin != null && $scope.companyList[i].marginAVGAS != null){ - fuelOrdersService.getFuelCost($scope.companyList[i].id).then(function(margins) { - $scope.marginList = margins; - //console.log('$scope.marginList', $scope.marginList); - }) - } else if ($scope.companyList[i].margin != null || $scope.companyList[i].marginAVGAS == null) { - fuelOrdersService.getATypeFuelPricing($scope.companyList[i].id).then(function(margins) { - $scope.marginList = margins; - }) - } else if ($scope.companyList[i].margin == null || $scope.companyList[i].marginAVGAS != null) { - fuelOrdersService.getVTypeFuelPricing($scope.companyList[i].id).then(function(margins) { - $scope.marginList = margins; - }) - } - $scope.selectedCompanyId = $scope.companyList[i].id; - $scope.marginId = $scope.companyList[i].margin.id; - if ($scope.selectedCompanyId != '') { - fuelOrdersService.getAircraft($scope.selectedCompanyId).then(function(aircraft) { - $scope.aircraftList = aircraft; - }) - } - if ($scope.marginId != '') { - fuelOrdersService.getJetTiers($scope.marginId).then(function(tiers) { - $scope.tierList = tiers; - // $scope.showLoader = false; - }) - }else{ - // $scope.showLoader = false; - } - } - } - - } - - $scope.setCost = function(cost){ - // console.log(cost); - if(cost != null) { - var obj =JSON.parse(cost); - // console.log("0bj",obj) - $scope.order.fboCost = obj.cost; - } - - } - - $scope.sourceList = [{source:"Direct Jet-A"},{source:"Direct AVGAS 100LL"}]; - $scope.cancelData = function() { - $('#demo-modal-4').css('display', ''); - } - - - - /*$scope.appendText = function() { - getData(); - var newRow = $(' -
{{row.companyName}} | @@ -508,200 +508,121 @@ -