2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 app.controller('postSearchCtrl', function ($scope,$http,ProfileService,modalService){
22 $scope.viewPerPage = 200;
23 $scope.currentPage = 1;
25 $scope.searchCategory = "";
26 $scope.searchString = "";
28 $scope.noResultsString = "";
30 ProfileService.getPostProfile().then(function(data){
33 $scope.data = JSON.parse(j.data);
35 $scope.postSearchBean =JSON.parse($scope.data.postSearchBean);
36 $scope.profileList =JSON.parse($scope.data.profileList);
37 $scope.ngexistingUsers=JSON.parse($scope.data.existingUsers);
38 $scope.ocisortByList=JSON.parse($scope.data.sortByList);
43 console.log("failed");
47 $scope.sortByList = [];
48 if($scope.ocisortByList)
49 $.each($scope.ocisortByList, function(i, a){
50 var sortBy = {"index":i, "value":a.value, "title":a.label};
51 $scope.sortByList.push(sortBy);
55 $scope.search = function(postSearchBean) {
56 console.log(postSearchBean);
57 var uuu = "post_search/search";
58 var postData={postSearchBean:postSearchBean};
63 contentType: 'application/json',
64 data: JSON.stringify(postData),
65 success : function(data){
66 $scope.$apply(function(){
67 $scope.profileList=data.users;
68 //$scope.postSearchBean={};
69 console.log($scope.profileList);
70 if($scope.profileList.length == 0)
71 $scope.noResultsString = "There is currently no one in WEBPHONE matching your search criteria.";
73 $scope.noResultsString = "";
76 error : function(data){
78 modalService.showFailure("Fail","Error while searching: "+ data.responseText);
84 $scope.reset = function() {
85 $scope.postSearchBean={};
86 $scope.profileList=[];
87 $scope.noResultsString = "";
88 //console.log($scope.postSearchBean);
91 $scope.process = function() {
92 $scope.prepareProfileSelection();
93 var uuu = "post_search/process";
94 var postData={postSearchBean:$scope.postSearchBean};
99 contentType: 'application/json',
100 data: JSON.stringify(postData),
101 success : function(data){
102 $scope.$apply(function(){
103 $scope.profileList=data.users;
104 //$scope.postSearchBean={};
105 $scope.ngexistingUsers=data.existingUsers;
106 $scope.postSearchBean.selected=null;
109 error : function(data){
111 modalService.showFailure("Fail","Error while searching: "+ data.responseText);
116 $scope.importProfileList=[];
117 $scope.toggleSelection = function(profile) {
119 $scope.importProfileList.push(profile);
121 var index = $scope.importProfileList.indexOf(profile);
123 $scope.importProfileList.splice(index, 1);
127 $scope.prepareProfileSelection = function() {
128 if($scope.importProfileList)
129 $.each($scope.importProfileList, function(i, profile){
130 $scope.preparePostSearchBean(profile);
135 $scope.preparePostSearchBean = function(profile) {
136 //console.log('Importing: '+profile.orgUserId);
137 //console.log('ngexistinguser:'+$scope.ngexistingUsers[profile.orgUserId])
138 if($scope.postSearchBean.selected==null){
139 $scope.postSearchBean.selected=[];
140 $scope.postSearchBean.postOrgUserId=[];
141 $scope.postSearchBean.postHrid=[];
142 $scope.postSearchBean.postFirstName=[];
143 $scope.postSearchBean.postLastName=[];
144 $scope.postSearchBean.postOrgCode=[];
145 $scope.postSearchBean.postPhone=[];
146 $scope.postSearchBean.postEmail=[];
147 $scope.postSearchBean.postAddress1=[];
148 $scope.postSearchBean.postAddress2=[];
149 $scope.postSearchBean.postCity=[];
150 $scope.postSearchBean.postState=[];
151 $scope.postSearchBean.postZipCode=[];
152 $scope.postSearchBean.postLocationClli=[];
153 $scope.postSearchBean.postBusinessCountryCode=[];
154 $scope.postSearchBean.postBusinessCountryName=[];
155 $scope.postSearchBean.postDepartment=[];
156 $scope.postSearchBean.postDepartmentName=[];
157 $scope.postSearchBean.postBusinessUnit=[];
158 $scope.postSearchBean.postBusinessUnitName=[];
159 $scope.postSearchBean.postJobTitle=[];
160 $scope.postSearchBean.postOrgManagerUserId=[];
161 $scope.postSearchBean.postCommandChain=[];
162 $scope.postSearchBean.postCompanyCode=[];
163 $scope.postSearchBean.postCompany=[];
164 $scope.postSearchBean.postCostCenter=[];
165 $scope.postSearchBean.postSiloStatus=[];
166 $scope.postSearchBean.postFinancialLocCode=[];
169 $scope.postSearchBean.selected.push(profile.orgUserId);
170 $scope.postSearchBean.postOrgUserId.push(profile.orgUserId);
171 $scope.postSearchBean.postHrid.push(profile.hrid);
172 $scope.postSearchBean.postFirstName.push(profile.firstName);
173 $scope.postSearchBean.postLastName.push(profile.lastName);
174 $scope.postSearchBean.postOrgCode.push(profile.orgCode);
175 $scope.postSearchBean.postPhone.push(profile.phone);
176 $scope.postSearchBean.postEmail.push(profile.email);
177 $scope.postSearchBean.postAddress1.push(profile.address1);
178 $scope.postSearchBean.postAddress2.push(profile.address2);
179 $scope.postSearchBean.postCity.push(profile.city);
180 $scope.postSearchBean.postState.push(profile.state);
181 if(profile.zipCodeSuffix==null)
182 $scope.postSearchBean.postZipCode.push(profile.zipCode);
184 $scope.postSearchBean.postZipCode.push(profile.zipCode+'-'+profile.zipCodeSuffix);
185 $scope.postSearchBean.postLocationClli.push(profile.locationClli);
186 $scope.postSearchBean.postBusinessCountryCode.push(profile.businessCountryCode);
187 $scope.postSearchBean.postBusinessCountryName.push(profile.businessCountryName);
188 $scope.postSearchBean.postDepartment.push(profile.department);
189 $scope.postSearchBean.postDepartmentName.push(profile.departmentName);
190 $scope.postSearchBean.postBusinessUnit.push(profile.businessUnit);
191 $scope.postSearchBean.postBusinessUnitName.push(profile.businessUnitName);
192 $scope.postSearchBean.postJobTitle.push(profile.jobTitle);
193 $scope.postSearchBean.postOrgManagerUserId.push(profile.orgManagerUserId);
194 $scope.postSearchBean.postCommandChain.push(profile.commandChain);
195 $scope.postSearchBean.postCompanyCode.push(profile.companyCode);
196 $scope.postSearchBean.postCompany.push(profile.company);
197 $scope.postSearchBean.postCostCenter.push(profile.costCenter);
198 $scope.postSearchBean.postSiloStatus.push(profile.siloStatus);
199 $scope.postSearchBean.postFinancialLocCode.push(profile.financialLocCode);