Blame view
app/partials/FuelVendors/FuelVendors.controller.js
6.21 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 |
|
1926e07b6
|
9 10 11 |
$(document).ready(function() { $('#example').DataTable(); }); |
a7a7cfeca
![]() |
12 |
$scope.userProfileId = JSON.parse(localStorage.getItem('userProfileId')) |
7152ff131
|
13 14 |
$scope.reset = function(){ $("input").val(""); |
a27f8c000
|
15 |
$scope.removeMarginValidation(); |
7152ff131
|
16 17 |
} |
1926e07b6
|
18 |
$scope.data = {}; |
1926e07b6
|
19 |
$scope.data.activate = true; |
d24318592
|
20 |
$scope.showLoader = false; |
cd330b5ee
|
21 22 23 24 25 |
getAllVendor(); function getAllVendor(){ FuelVendorsService.getAllVendor().then(function(result) { console.log(result) |
a27f8c000
|
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
$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
|
43 |
$scope.companyList[i].source = "Vendor" |
3a9f4472b
|
44 |
} |
a27f8c000
|
45 46 47 48 49 50 |
$scope.displayVendorList = new NgTableParams({ page: 1, count: 10, }, { data: $scope.companyList }); |
cd330b5ee
|
51 52 53 |
}) } |
3a9f4472b
|
54 55 |
$scope.editMargin = function(vendor){ console.log(vendor.masterMargin) |
52fea957f
|
56 |
$scope.showLoader = true; |
3a9f4472b
|
57 58 59 60 61 62 63 64 65 |
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
|
66 |
$scope.showLoader = false; |
3a9f4472b
|
67 68 69 70 |
toastr.success(''+result.success+'', { closeButton: true }) }else{ |
52fea957f
|
71 |
$scope.showLoader = false; |
3a9f4472b
|
72 73 74 75 76 77 |
toastr.error(''+result.statusText+'', { closeButton: true }) } }) } |
a7a7cfeca
![]() |
78 79 80 81 82 83 84 85 86 87 |
// 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
|
88 |
}) |
84d98f6ff
![]() |
89 90 91 92 93 94 95 96 97 98 99 100 101 |
$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
|
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
$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
|
116 |
|
1926e07b6
|
117 118 |
$scope.addFirstData = function(sel, step){ // console.log($scope.data) |
84d98f6ff
![]() |
119 120 121 122 123 124 125 126 127 128 129 130 131 |
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
|
132 |
|
84d98f6ff
![]() |
133 134 135 |
FuelVendorsService.addVendor(vendorData).then(function(result) { console.log("result",result) $scope.accountId = result; |
a27f8c000
|
136 137 |
$('#vendor-modal-3').modal('hide'); getAllVendor(); |
84d98f6ff
![]() |
138 |
}) |
84d98f6ff
![]() |
139 |
} |
a27f8c000
|
140 |
|
1926e07b6
|
141 |
} |
52fea957f
|
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
$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
|
157 |
|
1926e07b6
|
158 |
} |