Blame view
app/partials/FuelVendors/FuelVendors.controller.js
6.57 KB
4bb02bb84
|
1 2 3 4 |
'use strict'; //Load controller angular.module('acufuel') |
3a9f4472b
|
5 |
.controller('FuelVendorsController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'FuelVendorsService', 'CustomersService', 'ViewFuelVendorService', FuelVendorsController]); |
1926e07b6
|
6 |
|
3a9f4472b
|
7 |
function FuelVendorsController($scope, $rootScope, $uibModal, $filter, $http, FuelVendorsService, CustomersService, ViewFuelVendorService) { |
4bb02bb84
|
8 |
|
1926e07b6
|
9 10 11 |
$(document).ready(function() { $('#example').DataTable(); }); |
7152ff131
|
12 13 14 15 16 |
$scope.reset = function(){ $("input").val(""); } |
1926e07b6
|
17 18 19 |
$scope.data = {}; $scope.aircraft = {}; $scope.data.activate = true; |
d24318592
|
20 |
$scope.showLoader = false; |
cd330b5ee
|
21 22 23 24 25 26 |
getAllVendor(); function getAllVendor(){ FuelVendorsService.getAllVendor().then(function(result) { console.log(result) $scope.vendorList = result; |
3a9f4472b
|
27 28 29 |
for(var i=0; i<$scope.vendorList.length; i++){ $scope.vendorList[i].masterMargin = $scope.vendorList[i].margin.id; } |
cd330b5ee
|
30 31 32 |
}) } |
3a9f4472b
|
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
$scope.editMargin = function(vendor){ console.log(vendor.masterMargin) var companyMargin = "vendorName=" + vendor.vendorName + "&masterMargin=" + vendor.masterMargin + "&addressOne=" + vendor.addressOne + "&addressTwo=" + vendor.addressTwo + "&city=" + vendor.city + "&state=" + vendor.state + "&country=" + vendor.country + "&zipcode=" + vendor.zipcode + "&internalNote=" + vendor.internalNote + "&certificateType=" + vendor.certificateType + "&baseTenant=" + vendor.baseTenant + "&fuelerlinxvendor=" + vendor.fuelerlinxvendor + "&contractFuelVendor=" + vendor.contractFuelVendor + "&activate=" + vendor.activate + "&baseIcao=" + vendor.baseIcao + "&vendorId=" + vendor.id; ViewFuelVendorService.updateContact(companyMargin).then(function(result) { if(result != null && result.success){ toastr.success(''+result.success+'', { closeButton: true }) }else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }) } |
1926e07b6
|
55 56 57 58 59 60 |
getData(); function getData(){ CustomersService.getAircraftMake().then(function(result) { $scope.aircraftMakeList = result; }) } |
3a9f4472b
|
61 62 63 64 |
CustomersService.getMargin().then(function(result) { $scope.marginList = result; }) |
84d98f6ff
![]() |
65 66 67 68 69 70 71 72 73 74 75 76 77 |
$scope.showCompanyError = false; $scope.showMarginError = false; $scope.removeValidation = function(){ $scope.showCompanyError = false; $('.companyNameInput').removeClass('customErrorInput'); } $scope.removeMarginValidation = function(){ $scope.showMarginError = false; $('.marginSelectBox').removeClass('customErrorInput'); } |
3a9f4472b
|
78 |
|
1926e07b6
|
79 80 |
$scope.addFirstData = function(sel, step){ // console.log($scope.data) |
84d98f6ff
![]() |
81 82 83 84 85 86 87 88 89 90 91 92 93 |
if($scope.data.vendorName == undefined){ $scope.showCompanyError = true; $('.companyNameInput').addClass('customErrorInput'); }else if($scope.data.masterMargin == undefined){ $scope.showMarginError = true; $('.marginSelectBox').addClass('customErrorInput'); }else{ var vendorData = "vendorName=" + $scope.data.vendorName + "&masterMargin=" + $scope.data.masterMargin + "&addressOne=" + $scope.data.addressOne + "&addressTwo=" + $scope.data.addressTwo + "&city=" + $scope.data.city + "&state=" + $scope.data.state + "&country=" + $scope.data.country + "&zipcode=" + $scope.data.zipcode + "&internalNote=" + $scope.data.internalNote + "&certificateType=" + $scope.data.certificateType + "&baseTenant=" + $scope.data.baseTenant + "&fuelerlinxCustomer=" + $scope.data.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.data.contractFuelVendor + "&activate=" + $scope.data.activate + "&baseIcao=" + $scope.data.baseIcao; |
1926e07b6
|
94 |
|
84d98f6ff
![]() |
95 96 97 98 99 100 101 102 |
FuelVendorsService.addVendor(vendorData).then(function(result) { console.log("result",result) $scope.accountId = result; $scope.aircraft.accountId = $scope.accountId; }) $(sel).trigger('next.m.' + step); getData(); } |
1926e07b6
|
103 104 105 106 107 108 |
} $scope.aircraftDetails = [{ 'tail':'', 'make': '', 'model': '', |
3a9f4472b
|
109 110 |
'sizeId' : '', 'marginId': $scope.data.masterMargin |
1926e07b6
|
111 112 113 114 115 116 117 |
}]; $scope.addNew = function(){ $scope.aircraftDetails.push({ 'tail':'', 'make': '', 'model': '', |
3a9f4472b
|
118 119 |
'sizeId' : '', 'marginId': '' |
1926e07b6
|
120 121 122 123 124 |
}); console.log($scope.aircraftDetails) }; $scope.getModal = function(makeId, index){ |
d24318592
|
125 |
$scope.showLoader = true; |
1926e07b6
|
126 127 128 |
$scope.aircraft.make = makeId; //var makeId = makeId; CustomersService.getModal($scope.aircraft.make).then(function(result) { |
d24318592
|
129 |
$scope.showLoader = false; |
1926e07b6
|
130 131 132 133 134 135 |
$scope.aircraftDetails[index].aircraftModalList = result; //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; }) } $scope.getSize = function(model, index){ |
d24318592
|
136 |
$scope.showLoader = true; |
1926e07b6
|
137 |
CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { |
d24318592
|
138 |
$scope.showLoader = false; |
1926e07b6
|
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
console.log("result",result) $scope.aircraftDetails[index].aircraftSizeList = result; //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0]; console.log($scope.aircraftDetails[index].size) }) } $scope.aircraftListData = {}; $scope.addData = []; $scope.saveVendorData = function(){ for(var i=0; i<$scope.aircraftDetails.length;i++){ $scope.addData.push({ 'tail': $scope.aircraftDetails[i].tail, 'make': $scope.aircraftDetails[i].make, 'model': $scope.aircraftDetails[i].model, |
3a9f4472b
|
154 155 |
'sizeId' : $scope.aircraftDetails[i].sizeId, 'marginId': $scope.aircraftDetails[i].marginId |
1926e07b6
|
156 157 158 |
}); } $scope.aircraftListData.aircraftList = $scope.addData; |
cd330b5ee
|
159 |
$scope.aircraftListData.accountId = $scope.aircraft.accountId; |
1926e07b6
|
160 |
|
cd330b5ee
|
161 |
FuelVendorsService.addVendorAicraft($scope.aircraftListData).then(function(result) { |
1926e07b6
|
162 |
console.log(result) |
cd330b5ee
|
163 |
|
1926e07b6
|
164 165 166 167 |
if(result != null && result.success){ toastr.success(''+result.success+'', { closeButton: true }) |
cd330b5ee
|
168 169 |
$('#vendor-modal-3').modal('hide'); getAllVendor(); |
1926e07b6
|
170 171 172 173 174 175 176 177 |
}else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }); } } |