Blame view
app/partials/FuelVendors/FuelVendors.controller.js
5.54 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; } } |
3a9f4472b
|
43 |
} |
a27f8c000
|
44 45 46 47 48 49 |
$scope.displayVendorList = new NgTableParams({ page: 1, count: 10, }, { data: $scope.companyList }); |
cd330b5ee
|
50 51 52 |
}) } |
3a9f4472b
|
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
$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 }) } }) } |
a7a7cfeca
![]() |
75 76 77 78 79 80 81 82 83 84 |
// 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
|
85 |
}) |
84d98f6ff
![]() |
86 87 88 89 90 91 92 93 94 95 96 97 98 |
$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
|
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
$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
|
113 |
|
1926e07b6
|
114 115 |
$scope.addFirstData = function(sel, step){ // console.log($scope.data) |
84d98f6ff
![]() |
116 117 118 119 120 121 122 123 124 125 126 127 128 |
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
|
129 |
|
84d98f6ff
![]() |
130 131 132 |
FuelVendorsService.addVendor(vendorData).then(function(result) { console.log("result",result) $scope.accountId = result; |
a27f8c000
|
133 134 |
$('#vendor-modal-3').modal('hide'); getAllVendor(); |
84d98f6ff
![]() |
135 |
}) |
84d98f6ff
![]() |
136 |
} |
a27f8c000
|
137 |
|
1926e07b6
|
138 |
} |
1926e07b6
|
139 |
} |