Blame view
app/partials/FuelVendors/FuelVendors.controller.js
6.25 KB
4bb02bb84
|
1 2 3 4 |
'use strict'; //Load controller angular.module('acufuel') |
a27f8c000
|
5 |
.controller('FuelVendorsController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'FuelVendorsService', 'CustomersService', 'ViewFuelVendorService', 'NgTableParams', FuelVendorsController]); |
1926e07b6
|
6 |
|
a27f8c000
|
7 |
function FuelVendorsController($scope, $rootScope, $uibModal, $filter, $http, FuelVendorsService, CustomersService, ViewFuelVendorService, NgTableParams) { |
4bb02bb84
|
8 |
|
e196b9b74
|
9 |
/*$(document).ready(function() { |
9aae3d136
|
10 |
$scope.showLoader = true; |
1926e07b6
|
11 |
$('#example').DataTable(); |
9aae3d136
|
12 |
$scope.showLoader = false; |
e196b9b74
|
13 |
});*/ |
a7a7cfeca
![]() |
14 |
$scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')) |
7152ff131
|
15 16 |
$scope.reset = function(){ $("input").val(""); |
a27f8c000
|
17 |
$scope.removeMarginValidation(); |
7152ff131
|
18 19 |
} |
1926e07b6
|
20 |
$scope.data = {}; |
1926e07b6
|
21 |
$scope.data.activate = true; |
d24318592
|
22 |
$scope.showLoader = false; |
cd330b5ee
|
23 24 25 |
getAllVendor(); function getAllVendor(){ |
e196b9b74
|
26 |
$scope.showLoader = true; |
cd330b5ee
|
27 |
FuelVendorsService.getAllVendor().then(function(result) { |
e5448f302
|
28 |
//console.log(result) |
a27f8c000
|
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
$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; } } |
52fea957f
|
46 |
$scope.companyList[i].source = "Vendor" |
3a9f4472b
|
47 |
} |
a27f8c000
|
48 49 50 51 52 53 |
$scope.displayVendorList = new NgTableParams({ page: 1, count: 10, }, { data: $scope.companyList }); |
9aae3d136
|
54 |
$scope.showLoader = false; |
cd330b5ee
|
55 56 57 |
}) } |
3a9f4472b
|
58 |
$scope.editMargin = function(vendor){ |
52fea957f
|
59 |
$scope.showLoader = true; |
3a9f4472b
|
60 61 62 63 64 65 66 67 68 |
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){ |
52fea957f
|
69 |
$scope.showLoader = false; |
3a9f4472b
|
70 71 72 73 |
toastr.success(''+result.success+'', { closeButton: true }) }else{ |
52fea957f
|
74 |
$scope.showLoader = false; |
3a9f4472b
|
75 76 77 78 79 80 |
toastr.error(''+result.statusText+'', { closeButton: true }) } }) } |
a7a7cfeca
![]() |
81 82 83 84 85 86 87 88 89 90 |
// CustomersService.getMargin().then(function(result) { // $scope.marginList = result; // }) CustomersService.getJetMargin($scope.userProfileId).then(function(result) { $scope.jetMarginList = result; }) CustomersService.getAvgMargin($scope.userProfileId).then(function(result) { $scope.avgsMarginList = result; |
3a9f4472b
|
91 |
}) |
84d98f6ff
![]() |
92 93 94 95 96 97 98 99 100 101 102 103 104 |
$scope.showCompanyError = false; $scope.showMarginError = false; $scope.removeValidation = function(){ $scope.showCompanyError = false; $('.companyNameInput').removeClass('customErrorInput'); } $scope.removeMarginValidation = function(){ $scope.showMarginError = false; $('.marginSelectBox').removeClass('customErrorInput'); } |
a27f8c000
|
105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
$scope.marginFilterOptions = []; CustomersService.getJetMargin($scope.userProfileId).then(function(result) { $scope.jetMarginList = result; $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 }) } }) |
3a9f4472b
|
119 |
|
1926e07b6
|
120 121 |
$scope.addFirstData = function(sel, step){ // console.log($scope.data) |
84d98f6ff
![]() |
122 123 124 125 126 127 128 129 130 131 132 133 134 |
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
|
135 |
|
cdf775224
|
136 |
FuelVendorsService.addVendor($scope.data).then(function(result) { |
84d98f6ff
![]() |
137 |
$scope.accountId = result; |
a27f8c000
|
138 139 |
$('#vendor-modal-3').modal('hide'); getAllVendor(); |
84d98f6ff
![]() |
140 |
}) |
84d98f6ff
![]() |
141 |
} |
a27f8c000
|
142 |
|
1926e07b6
|
143 |
} |
52fea957f
|
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
$scope.exportVendors = function() { $scope.showLoader = true; var fileName = "vendors.csv"; var a = document.createElement("a"); document.body.appendChild(a); FuelVendorsService.exportVendors().then(function(result) { var file = new Blob([result], {type: 'application/csv'}); var fileURL = URL.createObjectURL(file); a.href = fileURL; a.download = fileName; a.click(); $scope.showLoader = false; }) } |
1926e07b6
|
159 |
|
1926e07b6
|
160 |
} |