Commit 55e075d7ef13a48e3f4e378acfe35e6f77f17ecc
1 parent
38429fc584
Exists in
master
add contact, add company with aircraft functionality implemented
Showing
8 changed files
with
421 additions
and
252 deletions
Show diff stats
app/js/app.js
app/partials/customers/customers.controller.js
... | ... | @@ -2,52 +2,20 @@ |
2 | 2 | |
3 | 3 | //Load controller |
4 | 4 | angular.module('acufuel') |
5 | - .controller('customersController', ['$scope', '$rootScope', '$uibModal', '$filter', 'CustomersService', customersController]); | |
5 | + .controller('customersController', ['$scope', '$rootScope', '$uibModal', '$filter', '$http', 'CustomersService', customersController]); | |
6 | 6 | |
7 | - function customersController($scope, $rootScope, $uibModal, $filter, CustomersService) { | |
7 | + function customersController($scope, $rootScope, $uibModal, $filter, $http, CustomersService) { | |
8 | 8 | $(document).ready(function() { |
9 | 9 | $('#example').DataTable(); |
10 | 10 | }); |
11 | 11 | $scope.data = {}; |
12 | 12 | $scope.aircraft = {}; |
13 | 13 | $scope.data.activate = true; |
14 | - $scope.customerList = [{ | |
15 | - "companyName": "Name and inc", | |
16 | - "Fleet": 3, | |
17 | - "phone":"1010101010", | |
18 | - "contact":"jimmy", | |
19 | - "Base":"Kiad", | |
20 | - "status":'Active', | |
21 | - "source": "tenant", | |
22 | - "allIn" : "$123" | |
23 | - },{ | |
24 | - "companyName": "Name and inc", | |
25 | - "Fleet": 3, | |
26 | - "phone":"1010101010", | |
27 | - "contact":"jimmy", | |
28 | - "Base":"Kiad", | |
29 | - "status":'Inactive', | |
30 | - "source": "tenant", | |
31 | - "allIn" : "$123" | |
32 | - },{ | |
33 | - "companyName": "Name and inc", | |
34 | - "Fleet": 3, | |
35 | - "phone":"1010101010", | |
36 | - "contact":"jimmy", | |
37 | - "Base":"Kiad", | |
38 | - "status":'Active', | |
39 | - "source": "tenant", | |
40 | - "allIn" : "$123" | |
41 | - },{ | |
42 | - "companyName": "Name and inc", | |
43 | - "Fleet": 3, | |
44 | - "phone":"1010101010", | |
45 | - "contact":"jimmy", | |
46 | - "Base":"Kiad", | |
47 | - "status":'Active', | |
48 | - "source": "tenant", | |
49 | - "allIn" : "$123" | |
50 | - }] | |
14 | + | |
15 | + CustomersService.getAllCompanies().then(function(result) { | |
16 | + console.log(result) | |
17 | + $scope.companyList = result; | |
18 | + }) | |
51 | 19 | |
52 | 20 | $(function() { |
53 | 21 | $('#toggle-one2').bootstrapToggle(); |
... | ... | @@ -62,168 +30,98 @@ |
62 | 30 | getData(); |
63 | 31 | function getData(){ |
64 | 32 | CustomersService.getAircraftMake().then(function(result) { |
65 | - console.log("result", result) | |
66 | 33 | $scope.aircraftMakeList = result; |
67 | - $scope.aircraft.make = $scope.aircraftMakeList[0]; | |
68 | - CustomersService.getModal($scope.aircraft.make).then(function(result) { | |
69 | - $scope.aircraftModalList = result; | |
70 | - $scope.aircraft.model = $scope.aircraftModalList[0]; | |
71 | - CustomersService.getAircraftSize($scope.aircraft.make, $scope.aircraft.model).then(function(result) { | |
72 | - $scope.aircraftSizeList = result; | |
73 | - $scope.aircraft.size = $scope.aircraftSizeList[0]; | |
74 | - }) | |
75 | - }) | |
76 | - | |
77 | 34 | }) |
78 | 35 | } |
79 | 36 | |
80 | - | |
81 | - $scope.getModal = function(){ | |
82 | - var makeId = $scope.aircraft.make; | |
83 | - CustomersService.getModal(makeId).then(function(result) { | |
84 | - $scope.aircraftModalList = result; | |
85 | - $scope.aircraft.model = $scope.aircraftModalList[0]; | |
86 | - CustomersService.getAircraftSize(makeId, $scope.aircraft.model).then(function(result) { | |
87 | - $scope.aircraftSizeList = result; | |
88 | - $scope.aircraft.size = $scope.aircraftSizeList[0]; | |
89 | - }) | |
90 | - }) | |
91 | - } | |
92 | - | |
93 | - $scope.getSize = function(){ | |
94 | - CustomersService.getAircraftSize($scope.aircraft.make, $scope.aircraft.model).then(function(result) { | |
95 | - $scope.aircraftSizeList = result; | |
96 | - $scope.aircraft.size = $scope.aircraftSizeList[0]; | |
97 | - }) | |
98 | - } | |
99 | - | |
100 | 37 | $scope.addFirstData = function(sel, step){ |
101 | 38 | // console.log($scope.data) |
102 | 39 | |
103 | - // var companyData = "companyName=" + $scope.data.companyName + "&masterMargin=" + $scope.data.masterMargin | |
104 | - // + "&addressOne=" + $scope.data.addressOne + "&addressTwo=" + $scope.data.addressTwo + "&city=" + $scope.data.city + "&state=" | |
105 | - // + $scope.data.state + "&country=" + $scope.data.country + "&zipcode=" + $scope.data.zipcode + "&internalNote=" | |
106 | - // + $scope.data.internalNote + "&certificateType=" + $scope.data.certificateType + "&baseTenant=" + $scope.data.baseTenant | |
107 | - // + "&fuelerlinxCustomer=" + $scope.data.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.data.contractFuelVendor | |
108 | - // + "&activate=" + $scope.data.activate + "&baseIcao=" + $scope.data.baseIcao; | |
109 | - | |
110 | - // CustomersService.addCompany(companyData).then(function(result) { | |
111 | - // console.log(result) | |
112 | - // $scope.accountId = result; | |
113 | - //$scope.aircraft.accountId = $scope.accountId; | |
114 | - // }) | |
40 | + var companyData = "companyName=" + $scope.data.companyName + "&masterMargin=" + $scope.data.masterMargin | |
41 | + + "&addressOne=" + $scope.data.addressOne + "&addressTwo=" + $scope.data.addressTwo + "&city=" + $scope.data.city + "&state=" | |
42 | + + $scope.data.state + "&country=" + $scope.data.country + "&zipcode=" + $scope.data.zipcode + "&internalNote=" | |
43 | + + $scope.data.internalNote + "&certificateType=" + $scope.data.certificateType + "&baseTenant=" + $scope.data.baseTenant | |
44 | + + "&fuelerlinxCustomer=" + $scope.data.fuelerlinxCustomer + "&contractFuelVendor=" + $scope.data.contractFuelVendor | |
45 | + + "&activate=" + $scope.data.activate + "&baseIcao=" + $scope.data.baseIcao; | |
46 | + | |
47 | + CustomersService.addCompany(companyData).then(function(result) { | |
48 | + console.log(result) | |
49 | + $scope.accountId = result; | |
50 | + $scope.aircraft.accountId = $scope.accountId; | |
51 | + }) | |
115 | 52 | $(sel).trigger('next.m.' + step); |
116 | 53 | getData(); |
117 | 54 | } |
118 | 55 | |
119 | - $scope.users = [ | |
120 | - {id: 1, name: 'awesome user1', status: 2, group: 4, groupName: 'admin'}, | |
121 | - {id: 2, name: 'awesome user2', status: undefined, group: 3, groupName: 'vip'}, | |
122 | - {id: 3, name: 'awesome user3', status: 2, group: null} | |
123 | - ]; | |
124 | - | |
125 | - $scope.statuses = [ | |
126 | - {value: 1, text: 'status1'}, | |
127 | - {value: 2, text: 'status2'}, | |
128 | - {value: 3, text: 'status3'}, | |
129 | - {value: 4, text: 'status4'} | |
130 | - ]; | |
131 | - | |
132 | - $scope.groups = []; | |
133 | - $scope.loadGroups = function() { | |
134 | - return $scope.groups.length ? null : $http.get('/groups').success(function(data) { | |
135 | - $scope.groups = data; | |
136 | - }); | |
137 | - }; | |
138 | - | |
139 | - $scope.showGroup = function(user) { | |
140 | - if(user.group && $scope.groups.length) { | |
141 | - var selected = $filter('filter')($scope.groups, {id: user.group}); | |
142 | - return selected.length ? selected[0].text : 'Not set'; | |
143 | - } else { | |
144 | - return user.groupName || 'Not set'; | |
145 | - } | |
146 | - }; | |
147 | - | |
148 | - $scope.showStatus = function(user) { | |
149 | - var selected = []; | |
150 | - if(user.status) { | |
151 | - selected = $filter('filter')($scope.statuses, {value: user.status}); | |
152 | - } | |
153 | - return selected.length ? selected[0].text : 'Not set'; | |
154 | - }; | |
155 | - | |
156 | - $scope.checkName = function(data, id) { | |
157 | - if (id === 2 && data !== 'awesome') { | |
158 | - return "Username 2 should be `awesome`"; | |
159 | - } | |
160 | - }; | |
161 | - | |
162 | - // filter users to show | |
163 | - $scope.filterUser = function(user) { | |
164 | - return user.isDeleted !== true; | |
165 | - }; | |
166 | - | |
167 | - // mark user as deleted | |
168 | - $scope.deleteUser = function(id) { | |
169 | - var filtered = $filter('filter')($scope.users, {id: id}); | |
170 | - if (filtered.length) { | |
171 | - filtered[0].isDeleted = true; | |
172 | - } | |
173 | - }; | |
174 | - | |
175 | - // add user | |
176 | - $scope.addUser = function() { | |
177 | - $scope.users.push({ | |
178 | - id: $scope.users.length+1, | |
179 | - name: '', | |
180 | - status: null, | |
181 | - group: null, | |
182 | - isNew: true | |
183 | - }); | |
184 | - }; | |
185 | - | |
186 | - // cancel all changes | |
187 | - $scope.cancel = function() { | |
188 | - for (var i = $scope.users.length; i--;) { | |
189 | - var user = $scope.users[i]; | |
190 | - // undelete | |
191 | - if (user.isDeleted) { | |
192 | - delete user.isDeleted; | |
193 | - } | |
194 | - // remove new | |
195 | - if (user.isNew) { | |
196 | - $scope.users.splice(i, 1); | |
197 | - } | |
198 | - }; | |
199 | - }; | |
200 | - | |
201 | - // save edits | |
202 | - $scope.saveTable = function() { | |
203 | - var results = []; | |
204 | - for (var i = $scope.users.length; i--;) { | |
205 | - var user = $scope.users[i]; | |
206 | - // actually delete user | |
207 | - if (user.isDeleted) { | |
208 | - $scope.users.splice(i, 1); | |
209 | - } | |
210 | - // mark as not new | |
211 | - if (user.isNew) { | |
212 | - user.isNew = false; | |
213 | - } | |
214 | - | |
215 | - // send on server | |
216 | - results.push($http.post('/saveUser', user)); | |
217 | - } | |
218 | - | |
219 | - return $q.all(results); | |
220 | - }; | |
56 | + $scope.aircraftDetails = [{ | |
57 | + 'tail':'', | |
58 | + 'make': '', | |
59 | + 'model': '', | |
60 | + 'size' : '' | |
61 | + }]; | |
62 | + | |
63 | + $scope.addNew = function(){ | |
64 | + $scope.aircraftDetails.push({ | |
65 | + 'tail':'', | |
66 | + 'make': '', | |
67 | + 'model': '', | |
68 | + 'size' : '' | |
69 | + }); | |
70 | + console.log($scope.aircraftDetails) | |
71 | + }; | |
72 | + | |
73 | + $scope.getModal = function(makeId, index){ | |
74 | + $scope.aircraft.make = makeId; | |
75 | + //var makeId = makeId; | |
76 | + CustomersService.getModal($scope.aircraft.make).then(function(result) { | |
77 | + $scope.aircraftDetails[index].aircraftModalList = result; | |
78 | + //$scope.aircraftDetails[index].model = $scope.aircraftModalList[0]; | |
79 | + }) | |
80 | + } | |
221 | 81 | |
222 | - $scope.appendText = function() { | |
223 | - getData(); | |
224 | - 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>'); | |
225 | - $('table.addRow').append(newRow); | |
226 | - } | |
82 | + $scope.getSize = function(model, index){ | |
83 | + CustomersService.getAircraftSize($scope.aircraft.make, model).then(function(result) { | |
84 | + $scope.aircraftDetails[index].aircraftSizeList = result; | |
85 | + //$scope.aircraftDetails[index].size = $scope.aircraftSizeList[0]; | |
86 | + console.log($scope.aircraftDetails[index].size) | |
87 | + }) | |
88 | + } | |
89 | + | |
90 | + $scope.aircraftListData = {}; | |
91 | + $scope.addData = []; | |
92 | + $scope.saveCompanyData = function(){ | |
93 | + for(var i=0; i<$scope.aircraftDetails.length;i++){ | |
94 | + $scope.addData.push({ | |
95 | + 'tail': $scope.aircraftDetails[i].tail, | |
96 | + 'make': $scope.aircraftDetails[i].make, | |
97 | + 'model': $scope.aircraftDetails[i].model, | |
98 | + 'size' : $scope.aircraftDetails[i].size | |
99 | + }); | |
100 | + } | |
101 | + $scope.aircraftListData.aircraftList = $scope.addData; | |
102 | + $scope.aircraftListData.accountId = $scope.aircraft.accountId; | |
103 | + | |
104 | + CustomersService.addAircraft($scope.aircraftListData).then(function(result) { | |
105 | + console.log(result) | |
106 | + if(result.success){ | |
107 | + toastr.success(''+result.success+'', { | |
108 | + closeButton: true | |
109 | + }) | |
110 | + $('#demo-modal-3').modal('hide'); | |
111 | + }else{ | |
112 | + toastr.error(''+result.statusText+'', { | |
113 | + closeButton: true | |
114 | + }) | |
115 | + } | |
116 | + }); | |
117 | + | |
118 | + } | |
119 | + | |
120 | + // $scope.appendText = function() { | |
121 | + // getData(); | |
122 | + // 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>'); | |
123 | + // $('table.addRow').append(newRow); | |
124 | + // } | |
227 | 125 | |
228 | 126 | |
229 | 127 | } |
230 | 128 | \ No newline at end of file | ... | ... |
app/partials/customers/customers.html
... | ... | @@ -142,15 +142,17 @@ |
142 | 142 | <th> </th> |
143 | 143 | </thead> |
144 | 144 | <tbody> |
145 | - <tr ng-repeat="customer in customerList"> | |
146 | - <td class="font-company">{{customer.companyName}}</td> | |
145 | + <tr ng-repeat="customer in companyList"> | |
146 | + <td class="font-company"> | |
147 | + <a style="color: #333; text-decoration: none;" href="#!/viewCompany/{{customer.id}}">{{customer.companyName}}</a> | |
148 | + </td> | |
147 | 149 | <td class="font-company">{{customer.Fleet}}</td> |
148 | 150 | <td class="font-company">{{customer.phone}}</td> |
149 | 151 | <td class="font-company">{{customer.contact}}</td> |
150 | - <td class="font-company">{{customer.Base}}</td> | |
152 | + <td class="font-company">{{customer.baseIcao}}</td> | |
151 | 153 | <td class="font-company"> |
152 | - <button type="button" ng-if="customer.status == 'Active'" class="btn btn-success btn-xs">{{customer.status}}</button> | |
153 | - <button type="button" ng-if="customer.status == 'Inactive'" class="btn btn-warning btn-xs">{{customer.status}}</button> | |
154 | + <button type="button" ng-if="customer.activate == true" class="btn btn-success btn-xs">Active</button> | |
155 | + <button type="button" ng-if="customer.activate == false" class="btn btn-warning btn-xs">InActive</button> | |
154 | 156 | </td> |
155 | 157 | </td> |
156 | 158 | <td class="font-company"> |
... | ... | @@ -300,7 +302,7 @@ |
300 | 302 | </div> |
301 | 303 | <!-- /main --> |
302 | 304 | |
303 | -<form class="modal multi-step" id="demo-modal-3" editable-form name="tableform" onaftersave="saveTable()" oncancel="cancel()"> | |
305 | +<form class="modal multi-step" id="demo-modal-3" name="companyForm"> | |
304 | 306 | <div class="modal-dialog modal-lg"> |
305 | 307 | <div class="modal-content"> |
306 | 308 | <div class="modal-body step-1" data-step="1" style="padding: 0;"> |
... | ... | @@ -541,54 +543,49 @@ |
541 | 543 | </tbody> |
542 | 544 | |
543 | 545 | </table> --> |
544 | - <table class="table table-bordered table-hover table-condensed"> | |
545 | - <tr style="font-weight: bold"> | |
546 | - <td style="width:40%">Name</td> | |
547 | - <td style="width:30%">Status</td> | |
548 | - <td style="width:30%">Group</td> | |
549 | - <td style="width:30%"><span ng-show="tableform.$visible">Action</span></td> | |
550 | - </tr> | |
551 | - <tr ng-repeat="user in users | filter:filterUser"> | |
552 | - <td> | |
553 | - <!-- editable username (text with validation) --> | |
554 | - <span editable-text="user.name" e-form="tableform" onbeforesave="checkName($data, user.id)"> | |
555 | - {{ user.name || 'empty' }} | |
556 | - </span> | |
557 | - </td> | |
558 | - <td> | |
559 | - <!-- editable status (select-local) --> | |
560 | - <span editable-select="user.status" e-form="tableform" e-ng-options="s.value as s.text for s in statuses"> | |
561 | - {{ showStatus(user) }} | |
562 | - </span> | |
563 | - </td> | |
564 | - <td> | |
565 | - <!-- editable group (select-remote) --> | |
566 | - <span editable-select="user.group" e-form="tableform" onshow="loadGroups()" e-ng-options="g.id as g.text for g in groups"> | |
567 | - {{ showGroup(user) }} | |
568 | - </span> | |
569 | - </td> | |
570 | - <td><button type="button" ng-show="tableform.$visible" ng-click="deleteUser(user.id)" class="btn btn-danger pull-right">Del</button></td> | |
571 | - </tr> | |
572 | - </table> | |
573 | - | |
574 | - <!-- buttons --> | |
575 | - <div class="btn-edit"> | |
576 | - <button type="button" class="btn btn-default" ng-show="!tableform.$visible" ng-click="tableform.$show()"> | |
577 | - edit | |
578 | - </button> | |
579 | - </div> | |
580 | - <div class="btn-form" ng-show="tableform.$visible"> | |
581 | - <button type="button" ng-disabled="tableform.$waiting" ng-click="addUser()" class="btn btn-default pull-right">add row</button> | |
582 | - <button type="submit" ng-disabled="tableform.$waiting" class="btn btn-primary">save</button> | |
583 | - <button type="button" ng-disabled="tableform.$waiting" ng-click="tableform.$cancel()" class="btn btn-default">cancel</button> | |
584 | - </div> | |
546 | + <table class="table table-striped table-bordered"> | |
547 | + <thead> | |
548 | + <tr> | |
549 | + <!-- <th><input type="checkbox" ng-model="selectedAll" ng-click="checkAll()" /></th> --> | |
550 | + <th>Tail</th> | |
551 | + <th>Make</th> | |
552 | + <th>Model</th> | |
553 | + <th>Size</th> | |
554 | + </tr> | |
555 | + </thead> | |
556 | + <tbody> | |
557 | + <tr ng-repeat="aircraftData in aircraftDetails track by $index"> | |
558 | + <!-- <td> | |
559 | + <input type="checkbox" ng-model="aircraftData.selected"/> | |
560 | + </td> --> | |
561 | + <td style="width: 20%"> | |
562 | + <input type="text" class="form-control" ng-model="aircraftData.tail" required/> | |
563 | + </td> | |
564 | + <td style="width: 20%"> | |
565 | + <select class="form-control" ng-model="aircraftData.make" ng-change="getModal(aircraftData.make, $index)"> | |
566 | + <option ng-repeat="make in aircraftMakeList">{{make}}</option> | |
567 | + </select> | |
568 | + </td> | |
569 | + <td style="width: 20%"> | |
570 | + <select class="form-control" ng-model="aircraftData.model" ng-change="getSize(aircraftData.model, $index)"> | |
571 | + <option ng-repeat="model in aircraftData.aircraftModalList">{{model}}</option> | |
572 | + </select> | |
573 | + </td> | |
574 | + <td style="width: 20%"> | |
575 | + <select class="form-control" ng-model="aircraftData.size"> | |
576 | + <option ng-repeat="size in aircraftData.aircraftSizeList">{{size}}</option> | |
577 | + </select> | |
578 | + </td> | |
579 | + </tr> | |
580 | + </tbody> | |
581 | + </table> | |
585 | 582 | </div> |
586 | 583 | <div class="clearfix"></div> |
587 | 584 | </div> |
588 | 585 | </div> |
589 | 586 | <div class="clearfix"></div> |
590 | 587 | <div class="col-xs-12" style="margin-bottom: 50px;margin-top: 10px;"> |
591 | - <button ng-click="appendText()" class="button1 turquoise pull-right"><span>+</span>Add Aircraft</button> | |
588 | + <button ng-click="addNew()" class="button1 turquoise pull-right"><span>+</span>Add Aircraft</button> | |
592 | 589 | </div> |
593 | 590 | <!-- <div class="col-xs-12" style="margin-bottom: 20px;"> |
594 | 591 | <div class="pull-right"> | ... | ... |
app/partials/customers/customers.service.js
... | ... | @@ -4,7 +4,23 @@ |
4 | 4 | .service('CustomersService', ['$q', '$http', 'BASE_URL', CustomersService]); |
5 | 5 | |
6 | 6 | function CustomersService($q, $http, BASE_URL) { |
7 | - | |
7 | + | |
8 | + this.getAllCompanies = function() { | |
9 | + | |
10 | + var deferred = $q.defer(); | |
11 | + $http({ | |
12 | + method : 'GET', | |
13 | + url : BASE_URL.url +'/user/allCompanies', | |
14 | + headers : {'Content-Type': 'application/json'}, | |
15 | + }) | |
16 | + .then(function (result){ | |
17 | + deferred.resolve(result.data); | |
18 | + },function (result){ | |
19 | + deferred.resolve(result.data); | |
20 | + }) | |
21 | + return deferred.promise; | |
22 | + } | |
23 | + | |
8 | 24 | this.addCompany = function(data) { |
9 | 25 | |
10 | 26 | var deferred = $q.defer(); |
... | ... | @@ -70,6 +86,23 @@ |
70 | 86 | return deferred.promise; |
71 | 87 | } |
72 | 88 | |
89 | + this.addAircraft = function(data){ | |
90 | + var deferred = $q.defer(); | |
91 | + $http({ | |
92 | + method : 'POST', | |
93 | + url : BASE_URL.url +'/company/add/aircrafts', | |
94 | + headers : {'Content-Type': 'application/json'}, | |
95 | + data: data | |
96 | + }) | |
97 | + .then(function (result){ | |
98 | + deferred.resolve(result.data); | |
99 | + },function (result){ | |
100 | + console.log(result) | |
101 | + deferred.resolve(result.data); | |
102 | + }) | |
103 | + return deferred.promise; | |
104 | + } | |
105 | + | |
73 | 106 | |
74 | 107 | |
75 | 108 | } | ... | ... |
app/partials/main/main.html
... | ... | @@ -80,7 +80,7 @@ |
80 | 80 | <b class="caret"></b> |
81 | 81 | </a> |
82 | 82 | <ul class="dropdown-menu"> |
83 | - <li><a ui-sref="app.viewCompany">View Companies</a></li> | |
83 | + <!-- <li><a ui-sref="app.viewCompany">View Companies</a></li> --> | |
84 | 84 | <li><a ui-sref="app.customers">View Contacts</a></li> |
85 | 85 | <li><a ui-sref="app.account">View Fuel Vendors</a></li> |
86 | 86 | <li><a ui-sref="app.analytics">Research Flight Dept</a></li> | ... | ... |
app/partials/viewCompany/viewCompany.controller.js
... | ... | @@ -4,10 +4,11 @@ |
4 | 4 | //Load controller |
5 | 5 | angular.module('acufuel') |
6 | 6 | |
7 | - .controller('viewCompanyController', ['$scope','$uibModal', function($scope , $uibModal) { | |
8 | - console.log("$uibModal",$uibModal); | |
7 | + .controller('viewCompanyController', ['$scope','$uibModal', '$stateParams', 'ViewCompanyService', function($scope , $uibModal, $stateParams, ViewCompanyService) { | |
8 | + $scope.data = {}; | |
9 | + $scope.data.priceEmail = true; | |
10 | + | |
9 | 11 | $scope.open = function(){ |
10 | - console.log("asndfsahdasd"); | |
11 | 12 | $scope.editSmsModal = $uibModal.open({ |
12 | 13 | templateUrl: 'partials/NewCompany/NewCompany.html', |
13 | 14 | backdrop: true, |
... | ... | @@ -29,8 +30,44 @@ |
29 | 30 | }) |
30 | 31 | $(function() { |
31 | 32 | $('#toggle-four').bootstrapToggle(); |
32 | - }) | |
33 | - | |
33 | + }) | |
34 | + | |
35 | + $(function() { | |
36 | + $('#price-one2').bootstrapToggle(); | |
37 | + $('#price-one2').change(function() { | |
38 | + $('#console-event').html('Toggle: ' + $(this).prop('checked')); | |
39 | + $scope.data.priceEmail = $(this).prop('checked'); | |
40 | + }) | |
41 | + }) | |
34 | 42 | |
35 | - }]); | |
43 | + var companyId = $stateParams.id; | |
44 | + console.log(companyId) | |
45 | + ViewCompanyService.getCompany(companyId).then(function(result) { | |
46 | + $scope.aircraftMakeList = result; | |
47 | + }) | |
48 | + | |
49 | + ViewCompanyService.getContact(companyId).then(function(result) { | |
50 | + $scope.aircraftMakeList = result; | |
51 | + }) | |
52 | + | |
53 | + $scope.contactData = {}; | |
54 | + $scope.contactData.contactList = []; | |
55 | + $scope.addContact = function(){ | |
56 | + $scope.data.companyId = companyId; | |
57 | + $scope.contactData.contactList.push($scope.data); | |
58 | + console.log($scope.contactData) | |
59 | + ViewCompanyService.addContact($scope.contactData).then(function(result) { | |
60 | + if(result.success){ | |
61 | + toastr.success(''+result.success+'', { | |
62 | + closeButton: true | |
63 | + }) | |
64 | + $('#contact-modal-3').modal('hide'); | |
65 | + }else{ | |
66 | + toastr.error(''+result.statusText+'', { | |
67 | + closeButton: true | |
68 | + }) | |
69 | + } | |
70 | + }) | |
71 | + } | |
36 | 72 | |
73 | + }]); | |
37 | 74 | \ No newline at end of file | ... | ... |
app/partials/viewCompany/viewCompany.html
... | ... | @@ -251,7 +251,7 @@ |
251 | 251 | <i class="fa fa-user"></i> |
252 | 252 | <h3>Contact List</h3> |
253 | 253 | <div class="pull-right"> |
254 | - <button type="submit" class="btn btn-success btn-sm" style="margin-top: 4px; margin-right: 9px;"><i class="icon-ok"></i>+   Add Contact</button> | |
254 | + <button type="submit" data-toggle="modal" data-target="#contact-modal-3" class="btn btn-success btn-sm" style="margin-top: 4px; margin-right: 9px;"><i class="icon-ok"></i>+   Add Contact</button> | |
255 | 255 | </div> |
256 | 256 | </div> |
257 | 257 | <div class="widget-content" style="padding:0px"> |
... | ... | @@ -366,6 +366,164 @@ |
366 | 366 | <!-- /widget --> |
367 | 367 | </div> |
368 | 368 | <!-- /container --> |
369 | +<form class="modal multi-step" id="contact-modal-3" name="companyForm"> | |
370 | + <div class="modal-dialog modal-lg"> | |
371 | + <div class="modal-content"> | |
372 | + <div class="modal-body step-1" data-step="1" style="padding: 0;"> | |
373 | + <div> | |
374 | + <div class="row" style="margin: 0;"> | |
375 | + <div> | |
376 | + <div class="widget" style="margin-bottom: 0; box-shadow: none;"> | |
377 | + <div class="widget-header"> | |
378 | + <i class="icon-pencil"></i> | |
379 | + <i class="fa fa-tasks" aria-hidden="true"></i> | |
380 | + <h3>Add a New Contact</h3> | |
381 | + <div class="clearfix"></div> | |
382 | + </div> | |
383 | + <div class="widget-content" style="padding-left: 0; padding-right: 0; border-bottom: 0;"> | |
384 | + <div class="col-xs-12"> | |
385 | + <div class="col-md-6"> | |
386 | + <div class="pull-left" style="width: 110px;"> | |
387 | + <label class="new-input-label"><b>First Name</b></label> | |
388 | + </div> | |
389 | + <div class="pull-left" style="margin-left: 15px;"> | |
390 | + <input type="tel" ng-model="data.firstName" class="form-control" placeholder=""> | |
391 | + </div> | |
392 | + <div class="clearfix"></div> | |
393 | + </div> | |
394 | + <div class="col-md-6"> | |
395 | + | |
396 | + <div class="pull-left" style="width: 110px;"> | |
397 | + <label class="new-input-label"><b>Last Name</b></label> | |
398 | + </div> | |
399 | + <div class="pull-left" style="margin-left: 15px;"> | |
400 | + <input type="tel" ng-model="data.lastName" class="form-control" id="Address" placeholder=""> | |
401 | + </div> | |
402 | + <div class="clearfix"></div> | |
403 | + </div> | |
404 | + </div> | |
405 | + <div class="clearfix"></div><br> | |
406 | + <div class="col-xs-12"> | |
407 | + <div class="col-md-6"> | |
408 | + <div class="pull-left" style="width: 110px;"> | |
409 | + <label class="new-input-label"><b>Title</b></label> | |
410 | + </div> | |
411 | + <div class="pull-left" style="margin-left: 15px;"> | |
412 | + <input type="tel" ng-model="data.title" class="form-control" id="Address" placeholder=""> | |
413 | + </div> | |
414 | + <div class="clearfix"></div> | |
415 | + </div> | |
416 | + <div class="col-md-6"> | |
417 | + | |
418 | + <div class="pull-left" style="width: 110px;"> | |
419 | + <label class="new-input-label"><b>Email</b></label> | |
420 | + </div> | |
421 | + <div class="pull-left" style="margin-left: 15px;"> | |
422 | + <input type="email" ng-model="data.email" class="form-control" id="Address" placeholder=""> | |
423 | + </div> | |
424 | + <div class="clearfix"></div> | |
425 | + </div> | |
426 | + </div> | |
427 | + <div class="clearfix"></div><br> | |
428 | + <div class="col-xs-12"> | |
429 | + <div class="col-md-6"> | |
430 | + <div class="pull-left" style="width: 110px;"> | |
431 | + <label class="new-input-label"><b>Username</b></label> | |
432 | + </div> | |
433 | + <div class="pull-left" style="margin-left: 15px;"> | |
434 | + <input type="tel" ng-model="data.userName" class="form-control" id="Address" placeholder=""> | |
435 | + </div> | |
436 | + <div class="clearfix"></div> | |
437 | + </div> | |
438 | + <div class="col-md-6"> | |
439 | + | |
440 | + <div class="pull-left" style="width: 110px;"> | |
441 | + <label class="new-input-label"><b>Password</b></label> | |
442 | + </div> | |
443 | + <div class="pull-left" style="margin-left: 15px;"> | |
444 | + <input type="password" ng-model="data.password" class="form-control" id="Address" placeholder=""> | |
445 | + </div> | |
446 | + <div class="clearfix"></div> | |
447 | + </div> | |
448 | + </div> | |
449 | + <div class="clearfix"></div><br> | |
450 | + <div class="col-xs-12"> | |
451 | + <div class="col-md-6"> | |
452 | + <div class="pull-left" style="width: 110px;"> | |
453 | + <label class="new-input-label"><b>Work Phone</b></label> | |
454 | + </div> | |
455 | + <div class="pull-left" style="margin-left: 15px;"> | |
456 | + <input type="tel" ng-model="data.workPhone" class="form-control" id="Address" placeholder=""> | |
457 | + </div> | |
458 | + <div class="clearfix"></div> | |
459 | + </div> | |
460 | + <div class="col-md-6"> | |
461 | + | |
462 | + <div class="pull-left" style="width: 110px;"> | |
463 | + <label class="new-input-label"><b>Mobile Phone</b></label> | |
464 | + </div> | |
465 | + <div class="pull-left" style="margin-left: 15px;"> | |
466 | + <input type="tel" ng-model="data.mobilePhone" class="form-control" id="Address" placeholder=""> | |
467 | + </div> | |
468 | + <div class="clearfix"></div> | |
469 | + </div> | |
470 | + </div> | |
471 | + <div class="clearfix"></div><br> | |
472 | + <div class="col-xs-12"> | |
473 | + <div class="col-md-12"> | |
474 | + <div class="pull-left" style="width: 110px;"> | |
475 | + <label class="new-input-label"><b>Address</b></label> | |
476 | + </div> | |
477 | + <div class="pull-right" style="width: calc(100% - 123px);"> | |
478 | + <input type="tel" class="form-control" ng-model="data.address" id="Address" placeholder=""> | |
479 | + </div> | |
480 | + <div class="clearfix"></div> | |
481 | + </div> | |
482 | + </div> | |
483 | + <div class="clearfix"></div> | |
484 | + <br/> | |
485 | + <div class="col-xs-12"> | |
486 | + <div class="col-md-3"> | |
487 | + <div class="pull-left my-toggle-switch"> | |
488 | + <div style="color: #ff9a01;">Price Email     | |
489 | + <input id="price-one2" checked type="checkbox" data-size="mini" data-width="55" data-toggle="toggle" data-on="On" data-off="Off"> | |
490 | + </div> | |
491 | + </div> | |
492 | + <div class="clearfix"></div> | |
493 | + </div> | |
494 | + <div class="col-md-3"> | |
495 | + <div class="pull-left my-toggle-switch"> | |
496 | + <div style="color: #ff9a01;">Primary Contact     | |
497 | + <input type="checkbox" ng-model="data.primaryContact"> | |
498 | + </div> | |
499 | + </div> | |
500 | + <div class="clearfix"></div> | |
501 | + </div> | |
502 | + <div class="col-md-6"> | |
503 | + <div class="pull-left" style="width: 110px;"> | |
504 | + <label class="new-input-label"><b>Internal Note</b></label> | |
505 | + </div> | |
506 | + <div class="pull-left" style="width: calc(100% - 110px);"> | |
507 | + <textarea name="message" ng-model="data.note" rows="4" cols="34"></textarea> | |
508 | + </div> | |
509 | + </div> | |
510 | + <div class="clearfix"></div> | |
511 | + </div> | |
512 | + <div class="clearfix"></div><br> | |
513 | + </div> | |
514 | + </div> | |
515 | + <div class="clearfix"></div> | |
516 | + </div> | |
517 | + </div> | |
518 | + </div> | |
519 | + </div> | |
520 | + <div class="modal-footer" style="border-top: 0;"> | |
521 | + <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> | |
522 | + <button type="button" class="btn btn-primary step step-1" data-step="1" ng-click="addContact()">Save</button> | |
523 | + </div> | |
524 | + </div> | |
525 | + </div> | |
526 | +</form> | |
369 | 527 | <div class="clearfix"></div> |
370 | 528 | <!-- Le javascript |
371 | 529 | ================================================== --> |
... | ... | @@ -375,4 +533,4 @@ |
375 | 533 | height: 250, |
376 | 534 | extraPlugins: 'divarea' |
377 | 535 | } ); |
378 | - </script> --> | |
379 | 536 | \ No newline at end of file |
537 | + </script> --> | ... | ... |
app/partials/viewCompany/viewCompany.service.js
1 | 1 | (function(){ |
2 | 2 | 'use strict'; |
3 | 3 | angular.module('acufuel') |
4 | - .service('viewCompanyService', ['$q', '$http', 'BE', viewCompanyService]); | |
5 | - | |
6 | - function viewCompanyService($q, $http, BE) { | |
7 | - var temp = {}; | |
4 | + .service('ViewCompanyService', ['$q', '$http', 'BASE_URL', ViewCompanyService]); | |
8 | 5 | |
6 | + function ViewCompanyService($q, $http, BASE_URL) { | |
9 | 7 | |
8 | + this.getCompany = function(id) { | |
9 | + | |
10 | + var deferred = $q.defer(); | |
11 | + $http({ | |
12 | + method : 'GET', | |
13 | + url : BASE_URL.url +'/company/'+id, | |
14 | + headers : {'Content-Type': 'application/json'}, | |
15 | + }) | |
16 | + .then(function (result){ | |
17 | + deferred.resolve(result.data); | |
18 | + },function (result){ | |
19 | + deferred.resolve(result.data); | |
20 | + }) | |
21 | + return deferred.promise; | |
22 | + } | |
23 | + | |
24 | + this.getContact = function(id) { | |
25 | + | |
26 | + var deferred = $q.defer(); | |
27 | + $http({ | |
28 | + method : 'GET', | |
29 | + url : BASE_URL.url +'/company/contact/'+id, | |
30 | + headers : {'Content-Type': 'application/json'}, | |
31 | + }) | |
32 | + .then(function (result){ | |
33 | + deferred.resolve(result.data); | |
34 | + },function (result){ | |
35 | + deferred.resolve(result.data); | |
36 | + }) | |
37 | + return deferred.promise; | |
38 | + } | |
39 | + | |
40 | + this.addContact = function(data) { | |
41 | + | |
42 | + var deferred = $q.defer(); | |
43 | + $http({ | |
44 | + method : 'POST', | |
45 | + url : BASE_URL.url +'/company/add/contact', | |
46 | + data : data, | |
47 | + headers : {'Content-Type': 'application/json'}, | |
48 | + }) | |
49 | + .then(function (result){ | |
50 | + deferred.resolve(result.data); | |
51 | + },function (result){ | |
52 | + deferred.resolve(result.data); | |
53 | + }) | |
54 | + return deferred.promise; | |
55 | + } | |
10 | 56 | |
11 | 57 | } |
12 | 58 | ... | ... |