Blame view
app/partials/viewCompany/viewCompany.controller.js
7.84 KB
feacde5ff
|
1 2 3 4 5 |
'use strict'; //Load controller angular.module('acufuel') |
b1f6160d4
|
6 |
.controller('viewCompanyController', ['$scope','$uibModal', '$stateParams', 'ViewCompanyService', 'CustomersService', function($scope , $uibModal, $stateParams, ViewCompanyService, CustomersService) { |
55e075d7e
|
7 8 |
$scope.data = {}; $scope.data.priceEmail = true; |
b1f6160d4
|
9 |
$scope.aircraft = {}; |
55e075d7e
|
10 |
|
4bb02bb84
|
11 |
$(function() { |
48ed0c7bb
|
12 |
$('#company-one2').bootstrapToggle(); |
4bb02bb84
|
13 |
}) |
feacde5ff
|
14 |
|
4bb02bb84
|
15 16 17 18 19 20 21 22 23 24 25 |
$(function() { $('#toggle-one1').bootstrapToggle(); }) $(function() { $('#toggle-two').bootstrapToggle(); }) $(function() { $('#toggle-three').bootstrapToggle(); }) $(function() { $('#toggle-four').bootstrapToggle(); |
55e075d7e
|
26 27 28 29 30 31 32 33 34 |
}) $(function() { $('#price-one2').bootstrapToggle(); $('#price-one2').change(function() { $('#console-event').html('Toggle: ' + $(this).prop('checked')); $scope.data.priceEmail = $(this).prop('checked'); }) }) |
feacde5ff
|
35 |
|
48ed0c7bb
|
36 |
var value = ""; |
55e075d7e
|
37 |
var companyId = $stateParams.id; |
55e075d7e
|
38 |
ViewCompanyService.getCompany(companyId).then(function(result) { |
b1f6160d4
|
39 |
$scope.companyData = result; |
48ed0c7bb
|
40 41 42 43 44 45 |
if($scope.companyData.activate == true){ value = 'on'; }else{ value = 'off' } $('#company-one2').bootstrapToggle(value) |
55e075d7e
|
46 |
}) |
48ed0c7bb
|
47 48 49 50 |
getContactList(); function getContactList(){ ViewCompanyService.getContact(companyId).then(function(result) { $scope.companyContactList = result; |
88dad9efc
|
51 52 53 54 55 56 57 58 59 60 61 |
for(var i=0;i<$scope.companyContactList.length; i++){ if($scope.companyContactList[i].priceEmail == true){ $scope.companyContactList[i].value1 = 'on'; console.log('aya') }else{ $scope.companyContactList[i].value1 = 'off'; } console.log($scope.companyContactList[i]) $('#'+$scope.companyContactList[i].id).bootstrapToggle($scope.companyContactList[i].value1) } |
48ed0c7bb
|
62 63 |
}) } |
55e075d7e
|
64 |
|
b1f6160d4
|
65 66 67 68 69 70 71 |
getAircraftList(); function getAircraftList(){ ViewCompanyService.getAircraft(companyId).then(function(result) { $scope.contactAircraftList = result; }) } |
55e075d7e
|
72 73 74 75 76 |
$scope.contactData = {}; $scope.contactData.contactList = []; $scope.addContact = function(){ $scope.data.companyId = companyId; $scope.contactData.contactList.push($scope.data); |
55e075d7e
|
77 78 79 80 81 82 |
ViewCompanyService.addContact($scope.contactData).then(function(result) { if(result.success){ toastr.success(''+result.success+'', { closeButton: true }) $('#contact-modal-3').modal('hide'); |
48ed0c7bb
|
83 |
getContactList(); |
55e075d7e
|
84 85 86 87 88 89 90 |
}else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }) } |
feacde5ff
|
91 |
|
b1f6160d4
|
92 93 94 95 96 97 98 99 100 101 102 |
getData(); function getData(){ CustomersService.getAircraftMake().then(function(result) { $scope.aircraftMakeList = result; }) } $scope.aircraftDetails = [{ 'tail':'', 'make': '', 'model': '', |
b6f0311a3
|
103 |
'sizeId' : '' |
b1f6160d4
|
104 105 106 107 108 109 110 |
}]; $scope.addNew = function(){ $scope.aircraftDetails.push({ 'tail':'', 'make': '', 'model': '', |
b6f0311a3
|
111 |
'sizeId' : '' |
b1f6160d4
|
112 |
}); |
b6f0311a3
|
113 |
console.log($scope.aircraftDetails) |
b1f6160d4
|
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
}; $scope.getModal = function(makeId, index){ $scope.aircraft.make = makeId; //var makeId = makeId; CustomersService.getModal($scope.aircraft.make).then(function(result) { $scope.aircraftDetails[index].aircraftModalList = result; //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; }) } $scope.getSize = function(model, index){ CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { $scope.aircraftDetails[index].aircraftSizeList = result; //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0]; }) } $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, |
b6f0311a3
|
140 |
'sizeId' : $scope.aircraftDetails[i].sizeId |
b1f6160d4
|
141 142 |
}); } |
b6f0311a3
|
143 |
console.log($scope.addData) |
b1f6160d4
|
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
$scope.aircraftListData.aircraftList = $scope.addData; $scope.aircraftListData.accountId = companyId; CustomersService.addAircraft($scope.aircraftListData).then(function(result) { if(result != null && result.success){ toastr.success(''+result.success+'', { closeButton: true }) $('#aircraft-modal-3').modal('hide'); getAircraftList(); }else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }); } $scope.showNoteData = true; $scope.showCompanyName = true; |
48ed0c7bb
|
164 |
$scope.showAddress = true; |
b1f6160d4
|
165 166 167 168 169 170 171 |
$scope.showNote = function(){ $scope.showNoteData = false; } $scope.company = function(){ $scope.showCompanyName = false; } |
48ed0c7bb
|
172 173 174 |
$scope.addressChange = function(){ $scope.showAddress = false; } |
b1f6160d4
|
175 |
$scope.editData = function(inputName) { |
48ed0c7bb
|
176 |
console.log($scope.companyData) |
b1f6160d4
|
177 178 179 180 |
if(inputName == 'showNoteData'){ $scope.showNoteData = true; }else if(inputName == 'showCompanyName'){ $scope.showCompanyName = true; |
48ed0c7bb
|
181 182 |
}else if(inputName == 'showAddress'){ $scope.showAddress = true; |
b1f6160d4
|
183 |
} |
48ed0c7bb
|
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
var companyData = "companyName=" + $scope.companyData.companyName + "&masterMargin=" + $scope.companyData.masterMargin + "&addressOne=" + $scope.companyData.addressOne + "&addressTwo=" + $scope.companyData.addressTwo + "&city=" + $scope.companyData.city + "&state=" + $scope.companyData.state + "&country=" + $scope.companyData.country + "&zipcode=" + $scope.companyData.zipcode + "&internalNote=" + $scope.companyData.internalNote + "&certificateType=" + $scope.companyData.certificateType + "&baseTenant=" + $scope.companyData.baseTenant + "&fuelerlinxCustomer=" + $scope.companyData.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.companyData.contractFuelVendor + "&activate=" + $scope.companyData.activate + "&baseIcao=" + $scope.companyData.baseIcao + "&companyId=" + companyId; ViewCompanyService.updateContact(companyData).then(function(result) { if(result != null && result.success){ toastr.success(''+result.success+'', { closeButton: true }) }else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }) |
b1f6160d4
|
203 204 |
} |
fd20aa6ce
|
205 206 207 208 209 210 211 212 213 214 215 216 217 |
$scope.sendMail = function(){ ViewCompanyService.sendMail(companyId).then(function(result) { if(result != null && result.success){ toastr.success(''+result.success+'', { closeButton: true }) }else{ toastr.error(''+result.statusText+'', { closeButton: true }) } }) } |
55e075d7e
|
218 |
}]); |