Blame view
app/partials/customers/customers.controller.js
7.17 KB
feacde5ff
|
1 2 3 4 |
'use strict'; //Load controller angular.module('acufuel') |
3a9f4472b
|
5 |
.controller('customersController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'CustomersService', 'ViewCompanyService', customersController]); |
feacde5ff
|
6 |
|
3a9f4472b
|
7 |
function customersController($scope, $rootScope, $uibModal, $filter, $http, CustomersService, ViewCompanyService) { |
4bb02bb84
|
8 9 10 |
$(document).ready(function() { $('#example').DataTable(); }); |
7152ff131
|
11 12 13 14 15 |
$scope.reset2 = function(){ $("input").val(""); } |
4bb02bb84
|
16 17 18 |
$scope.data = {}; $scope.aircraft = {}; $scope.data.activate = true; |
d24318592
|
19 |
$scope.showLoader = false; |
b6f0311a3
|
20 21 22 23 |
getAllCompanies(); function getAllCompanies(){ CustomersService.getAllCompanies().then(function(result) { |
b6f0311a3
|
24 |
$scope.companyList = result; |
3a9f4472b
|
25 26 27 |
for(var i=0; i<$scope.companyList.length; i++){ $scope.companyList[i].masterMargin = $scope.companyList[i].margin.id; } |
b6f0311a3
|
28 29 |
}) } |
feacde5ff
|
30 |
|
3a9f4472b
|
31 |
$scope.editMargin = function(customer){ |
d24318592
|
32 |
event.stopPropagation(); |
3a9f4472b
|
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
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.updateContact(companyMargin).then(function(result) { if(result != null && result.success){ toastr.success(''+result.success+'', { closeButton: true }) }else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }) } |
4bb02bb84
|
53 54 55 56 57 |
getData(); function getData(){ CustomersService.getAircraftMake().then(function(result) { |
4bb02bb84
|
58 |
$scope.aircraftMakeList = result; |
4bb02bb84
|
59 60 |
}) } |
3a9f4472b
|
61 62 63 64 |
CustomersService.getMargin().then(function(result) { $scope.marginList = result; }) |
32286a73a
![]() |
65 66 67 68 |
$scope.showCompanyError = false; $scope.showMarginError = false; $scope.removeValidation = function(){ |
32286a73a
![]() |
69 70 71 72 73 74 75 76 |
$scope.showCompanyError = false; $('.companyNameInput').removeClass('customErrorInput'); } $scope.removeMarginValidation = function(){ $scope.showMarginError = false; $('.marginSelectBox').removeClass('customErrorInput'); } |
3a9f4472b
|
77 |
|
4bb02bb84
|
78 |
$scope.addFirstData = function(sel, step){ |
3a9f4472b
|
79 |
if($scope.data.companyName == undefined){ |
32286a73a
![]() |
80 81 |
$scope.showCompanyError = true; $('.companyNameInput').addClass('customErrorInput'); |
3a9f4472b
|
82 |
}else if($scope.data.masterMargin == undefined){ |
32286a73a
![]() |
83 84 |
$scope.showMarginError = true; $('.marginSelectBox').addClass('customErrorInput'); |
3a9f4472b
|
85 86 87 88 89 90 91 |
}else{ var companyData = "companyName=" + $scope.data.companyName + "&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; |
4bb02bb84
|
92 |
|
3a9f4472b
|
93 |
CustomersService.addCompany(companyData).then(function(result) { |
3a9f4472b
|
94 95 96 97 98 99 |
$scope.accountId = result; $scope.aircraft.accountId = $scope.accountId; }) $(sel).trigger('next.m.' + step); getData(); } |
4bb02bb84
|
100 |
} |
55e075d7e
|
101 102 103 104 |
$scope.aircraftDetails = [{ 'tail':'', 'make': '', 'model': '', |
3a9f4472b
|
105 106 |
'sizeId' : '', 'marginId': $scope.data.masterMargin |
55e075d7e
|
107 108 109 110 111 112 113 |
}]; $scope.addNew = function(){ $scope.aircraftDetails.push({ 'tail':'', 'make': '', 'model': '', |
3a9f4472b
|
114 115 |
'sizeId' : '', 'marginId': '' |
55e075d7e
|
116 |
}); |
55e075d7e
|
117 118 119 |
}; $scope.getModal = function(makeId, index){ |
d24318592
|
120 |
$scope.showLoader = true; |
55e075d7e
|
121 122 123 |
$scope.aircraft.make = makeId; //var makeId = makeId; CustomersService.getModal($scope.aircraft.make).then(function(result) { |
d24318592
|
124 |
$scope.showLoader = false; |
55e075d7e
|
125 126 127 128 |
$scope.aircraftDetails[index].aircraftModalList = result; //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; }) } |
4bb02bb84
|
129 |
|
55e075d7e
|
130 |
$scope.getSize = function(model, index){ |
d24318592
|
131 |
$scope.showLoader = true; |
55e075d7e
|
132 |
CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { |
d24318592
|
133 |
$scope.showLoader = false; |
7152ff131
|
134 |
$scope.aircraftDetails[index].aircraftSizeList = result; |
55e075d7e
|
135 |
//$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0]; |
55e075d7e
|
136 137 138 139 140 141 142 143 144 145 146 |
}) } $scope.aircraftListData = {}; $scope.addData = []; $scope.saveCompanyData = 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
|
147 148 |
'sizeId' : $scope.aircraftDetails[i].sizeId, 'marginId': $scope.aircraftDetails[i].marginId |
55e075d7e
|
149 150 151 152 153 154 |
}); } $scope.aircraftListData.aircraftList = $scope.addData; $scope.aircraftListData.accountId = $scope.aircraft.accountId; CustomersService.addAircraft($scope.aircraftListData).then(function(result) { |
b6f0311a3
|
155 |
|
b1f6160d4
|
156 |
if(result != null && result.success){ |
55e075d7e
|
157 158 159 160 |
toastr.success(''+result.success+'', { closeButton: true }) $('#demo-modal-3').modal('hide'); |
b6f0311a3
|
161 |
getAllCompanies(); |
55e075d7e
|
162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
}else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }); } // $scope.appendText = function() { // getData(); // var newRow = $('<tr> <td> <input type="text" style="width:100px;" ng-model="aircraft.tail" class="form-control"> </td> <td style="width: 25%;"> <select class="form-control" ng-model="aircraft.make" ng-change="getModal()"> <option ng-repeat="make in aircraftMakeList">{{make}}</option> </select> </td> <td style="width: 20%;"> <select class="form-control" ng-model="aircraft.model" ng-change="getSize()"> <option ng-repeat="model in aircraftModalList">{{model}}</option> </select> </td> <td style="width: 25%;"> <select class="form-control" ng-model="aircraft.size"> <option ng-repeat="size in aircraftSizeList">{{size}}</option> </select> </td> <td> <select class="form-control"> <option>Margin1</option> <option>Margin2</option> </select> </td> </tr>'); // $('table.addRow').append(newRow); // } |
4bb02bb84
|
176 177 178 |
} |