nexus site path corrected
[portal.git] / ecomp-portal-BE / war / WEB-INF / fusion / jsp / post_search.jsp
1 <%--
2   ================================================================================
3   eCOMP Portal
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
10   
11        http://www.apache.org/licenses/LICENSE-2.0
12   
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   ================================================================================
19   --%>
20 <%@ page import="java.util.*" %>
21 <%@ page import="com.fasterxml.jackson.databind.ObjectMapper" %>
22 <%@ page import="org.json.JSONObject" %>
23
24 <%-- <%@ include file="/WEB-INF/fusion/jsp/include.jsp"%> --%>
25
26 <%@ taglib prefix="c"      uri="http://java.sun.com/jsp/jstl/core" %>
27 <%@ taglib prefix="fmt"    uri="http://java.sun.com/jsp/jstl/fmt" %>
28 <%@ taglib prefix="fn"     uri="http://java.sun.com/jsp/jstl/functions" %>
29
30 <link rel="stylesheet" type="text/css" href="static/fusion/css/jquery-ui.css">
31
32 <script src= "static/ebz/angular_js/angular.js"></script> 
33 <script src= "static/ebz/angular_js/angular-sanitize.js"></script>
34 <script src="static/ebz/sandbox/att-abs-tpls.js" type="text/javascript"></script>
35 <script src= "static/ebz/angular_js/app.js"></script>
36 <script src= "static/ebz/angular_js/gestures.js"></script>
37 <script src="static/js/jquery-1.10.2.js"></script>
38 <script src="static/js/modalService.js"></script>
39 <script src="static/js/jquery.mask.min.js" type="text/javascript"></script>
40 <script src="static/js/jquery-ui.js" type="text/javascript"></script>
41
42 <div ng-controller="postSearchController" >
43
44 <h1 class="heading1" style="margin-top:20px;">WEBPHONE Search</h1>
45                 <%-- <h3>
46       <div class="pageTitle"><fmt:message key="post-search.title"/></div>
47       </h3> --%>
48       <br>
49                 Please enter search criteria below:<br/>
50
51             <div class="fn-ebz-container">
52                   Last Name:<br/>
53                   <input class="fn-ebz-text" type="text"   ng-model="postSearchBean.lastName" value="" size="25">
54             </div>
55           
56             <div class="fn-ebz-container">
57                   First Name:<br/>
58                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.firstName" value="" size="25">
59             </div>
60          
61             <div class="fn-ebz-container">
62                   ATTUID:<br/>
63                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.sbcid" value="" size="25">
64             </div>
65            
66             <div class="fn-ebz-container">
67                   Manager ATTUID:<br/>
68                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.managerAttuid" value="" size="25">
69             </div>
70            <br>
71             <div class="fn-ebz-container">
72                   Organization:<br/>
73                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.orgCode" value="" size="25">
74             </div>
75            
76             <div class="fn-ebz-container">
77                   Email:<br/>
78                   <input class="fn-ebz-text" type="text" ng-model="postSearchBean.email" value="" size="25">
79             </div>
80      <br>
81 <!--      Sort By: <br/>
82                 <div class="fn-ebz-container" >
83        
84                 <div class="fn-ebz-container">  
85                         <div class="form-field" att-select="sortByList" ng-model="postSearchBean.sortBy1"></div>
86                 </div>
87         </div>
88         
89        
90         
91
92             <div class="fn-ebz-container" >
93            <br/>
94             &nbsp;
95
96                 <div class="fn-ebz-container">  
97                         <div class="form-field" att-select="sortByList" ng-model="postSearchBean.sortBy2"></div>
98                 </div>
99        </div>
100         
101
102             <div class="fn-ebz-container" >
103             <br/> &nbsp;
104
105                 <div class="fn-ebz-container">  
106                         <div class="form-field" att-select="sortByList" ng-model="postSearchBean.sortBy3"></div>
107                 </div>
108         </div> -->
109                 <div>
110                         <input att-button btn-type="primary" size="small" class="button" type="submit" value="Search" ng-click="search(postSearchBean);" />
111                 
112                      <input att-button btn-type="primary" size="small" class="button" type="submit" value="Reset"  ng-click="reset();"/>
113                 </div>
114                 <br>
115                 {{noResultsString}}
116       <div ng-if="profileList.length != 0">
117             <table att-table table-data="profileList" view-per-page="viewPerPage" current-page="currentPage" search-category="searchCategory" search-string="searchString" total-page="totalPage">
118                   <thead att-table-row type="header" >
119                     <tr>
120                         <th att-table-header  width="5%" align="left">No</th>
121                         <th att-table-header  width="30%" key="lastName" align="left">Name</th>
122                         <th att-table-header  width="5%"  key="sbcid" align="left">ATTUID</th>
123                         <th att-table-header  width="10%" key="orgCode" align="left">Organization</th>
124                         <th att-table-header  width="20%" align="left">Phone</th>
125                         <th att-table-header  width="20%" key="email" align="left">Email</th>
126                         <th att-table-header  width="10%" align="left">Import?</th>
127                         </tr>
128                   </thead>
129                 
130             <tbody att-table-row type="body" row-repeat="profile in profileList" style="max-height: 980px;" ><!-- background colors will alternate not properly with multiple tbody-->  
131               <tr >
132                 <td att-table-body width="5%" align="left">
133                 {{$index + 1}}
134                 </td>
135                 <td att-table-body width="30%" align="left">                    
136                       <div ng-if="ngexistingUsers[profile.sbcid] == null">
137                           {{profile.lastName}},&nbsp;{{profile.firstName}}
138                   </div>
139                       <div ng-if="ngexistingUsers[profile.sbcid] != null">
140                       <a href="profile.htm?profile_id={{ngexistingUsers[profile.sbcid]}}" alt="View/Edit Profile">
141                           {{profile.lastName}},&nbsp;{{profile.firstName}}
142                           </a>
143                    </div>
144                
145                 </td>
146                 <td att-table-body width="5%" align="left">
147                 {{profile.sbcid}}
148                 </td>
149                 <td att-table-body width="10%" align="left">
150                 {{profile.orgCode}}
151                 </td>
152                 <td att-table-body width="20%" align="left">
153                 {{profile.phone}}
154                 </td>
155                 <td att-table-body width="20%" align="left">
156                 {{profile.email}}
157                 </td>
158                 
159                 <td att-table-body width="10%" align="left">
160                             <div ng-if="ngexistingUsers[profile.sbcid] == null">
161                                 <div ng-click="toggleSelection(profile);">
162                                 <input name="selected" type="checkbox" ng-model="profile.selected" att-checkbox/>
163                                 </div>
164                              </div>
165                              <div ng-if="ngexistingUsers[profile.sbcid] != null">
166                                 Exists
167                              </div>
168                 </td>
169               </tr>
170               </tbody>
171             </table>
172             <div class="fn-ebz-container">
173                   Rows Per Page:
174                   <input class="fn-ebz-text" type="text" ng-model="viewPerPage" size="5" style="width: 47px;">
175         </div>
176                 <div class="fn-ebz-container">
177                   Current Page:
178                   <input class="fn-ebz-text" type="text" ng-model="currentPage" size="5" style="width: 47px;">
179         </div>
180         <div class="fn-ebz-container">
181                   Total Page(s):
182                   <input class="fn-ebz-text" type="text" ng-model="totalPage" size="5" readonly="true" style="width: 47px;">
183         </div>
184                 
185         <div ng-if="profileList.length != 0">
186           <input att-button btn-type="primary" size="small" class="button" type="submit" value="Import" ng-click="process();"/>
187         </div>
188
189       </div>
190
191
192
193
194 </div>
195 <script>
196         app.controller('postSearchController', function ($scope){ 
197
198                 $scope.viewPerPage = 200;
199                 $scope.currentPage = 1;
200                 $scope.totalPage;
201                 $scope.searchCategory = "";
202                 $scope.searchString = "";
203                 
204                 $scope.noResultsString = "";
205                 
206                 $scope.postSearchBean=${postSearchBean};
207                 $scope.profileList=${profileList};
208                 //console.log($scope.postSearchBean);
209                 
210                 $scope.ngexistingUsers=${existingUsers};
211                 console.log($scope.ngexistingUsers);
212                 
213                 $scope.ocisortByList=${sortByList};
214                 $scope.sortByList = [];
215                 if($scope.ocisortByList)
216                 $.each($scope.ocisortByList, function(i, a){ 
217                         var sortBy = {"index":i, "value":a.value, "title":a.label};
218                     $scope.sortByList.push(sortBy);
219                 });     
220                 ;
221         
222                 $scope.search = function(postSearchBean) {
223                                 console.log(postSearchBean);
224                                 var uuu = "post_search/search";
225                                   var postData={postSearchBean:postSearchBean};
226                                   $.ajax({
227                                          type : 'POST',
228                                          url : uuu,
229                                          dataType: 'json',
230                                          contentType: 'application/json',
231                                          data: JSON.stringify(postData),
232                                          success : function(data){
233                                                 $scope.$apply(function(){
234                                                         $scope.profileList=data.postSearchBean.searchResult;
235                                                         //$scope.postSearchBean={};
236                                                         console.log($scope.profileList);
237                                                         if($scope.profileList.length == 0)
238                                                                 $scope.noResultsString = "There is currently no one matching your search criteria.";
239                                                         else
240                                                                 $scope.noResultsString = "";
241                                                         });  
242                                          },
243                                          error : function(data){
244                                                  console.log(data);
245                                                  alert("Error while searching: "+ data.responseText);
246                                          }
247                                   });
248                         
249                 };
250                 
251                 $scope.reset = function() {
252                                 $scope.postSearchBean={};
253                                 $scope.profileList=[];
254                                 $scope.noResultsString = "";
255                                 //console.log($scope.postSearchBean);
256                 };
257                 
258                 $scope.process = function() {
259                         $scope.prepareProfileSelection();
260                         var uuu = "post_search/process";
261                           var postData={postSearchBean:$scope.postSearchBean};
262                           $.ajax({
263                                  type : 'POST',
264                                  url : uuu,
265                                  dataType: 'json',
266                                  contentType: 'application/json',
267                                  data: JSON.stringify(postData),
268                                  success : function(data){
269                                         $scope.$apply(function(){
270                                                 $scope.profileList=data.postSearchBean.searchResult;
271                                                 //$scope.postSearchBean={};
272                                                 $scope.ngexistingUsers=data.existingUsers;
273                                                 $scope.postSearchBean.selected=null;                                            
274                                                 });  
275                                  },
276                                  error : function(data){
277                                          console.log(data);
278                                          alert("Error while searching: "+ data.responseText);
279                                  }
280                           });
281                 
282         };
283         $scope.importProfileList=[];
284         $scope.toggleSelection = function(profile) {
285                 if(profile.selected)
286                         $scope.importProfileList.push(profile);
287                 else{                   
288                         var index = $scope.importProfileList.indexOf(profile);
289                         if(index>=0)
290                                 $scope.importProfileList.splice(index, 1);
291                 }
292         };
293         
294         $scope.prepareProfileSelection = function() {
295                 if($scope.importProfileList)
296                         $.each($scope.importProfileList, function(i, profile){ 
297                             $scope.preparePostSearchBean(profile);
298                         });     
299                         ;
300         }
301         
302         $scope.preparePostSearchBean = function(profile) {
303                 //console.log('Importing: '+profile.sbcid);
304                 //console.log('ngexistinguser:'+$scope.ngexistingUsers[profile.sbcid])
305                 if($scope.postSearchBean.selected==null){
306                         $scope.postSearchBean.selected=[];
307                         $scope.postSearchBean.postSbcid=[];
308                         $scope.postSearchBean.postHrid=[];
309                         $scope.postSearchBean.postFirstName=[];
310                         $scope.postSearchBean.postLastName=[];
311                         $scope.postSearchBean.postOrgCode=[];
312                         $scope.postSearchBean.postPhone=[];
313                         $scope.postSearchBean.postEmail=[];
314                         $scope.postSearchBean.postAddress1=[];
315                         $scope.postSearchBean.postAddress2=[];
316                         $scope.postSearchBean.postCity=[];
317                         $scope.postSearchBean.postState=[];
318                         $scope.postSearchBean.postZipCode=[];
319                         $scope.postSearchBean.postLocationClli=[];
320                         $scope.postSearchBean.postBusinessCountryCode=[];
321                         $scope.postSearchBean.postBusinessCountryName=[];
322                         $scope.postSearchBean.postDepartment=[];
323                         $scope.postSearchBean.postDepartmentName=[];
324                         $scope.postSearchBean.postBusinessUnit=[];
325                         $scope.postSearchBean.postBusinessUnitName=[];
326                         $scope.postSearchBean.postJobTitle=[];
327                         $scope.postSearchBean.postManagerAttuid=[];
328                         $scope.postSearchBean.postCommandChain=[];
329                         $scope.postSearchBean.postCompanyCode=[];
330                         $scope.postSearchBean.postCompany=[];
331                         $scope.postSearchBean.postCostCenter=[];
332                         $scope.postSearchBean.postSiloStatus=[];
333                         $scope.postSearchBean.postFinancialLocCode=[];
334                 }
335                         
336                 $scope.postSearchBean.selected.push(profile.sbcid);     
337                 $scope.postSearchBean.postSbcid.push(profile.sbcid);
338                 $scope.postSearchBean.postHrid.push(profile.hrid);
339                 $scope.postSearchBean.postFirstName.push(profile.firstName);
340                 $scope.postSearchBean.postLastName.push(profile.lastName);
341                 $scope.postSearchBean.postOrgCode.push(profile.orgCode);
342                 $scope.postSearchBean.postPhone.push(profile.phone);
343                 $scope.postSearchBean.postEmail.push(profile.email);
344                 $scope.postSearchBean.postAddress1.push(profile.address1);
345                 $scope.postSearchBean.postAddress2.push(profile.address2);
346                 $scope.postSearchBean.postCity.push(profile.city);
347                 $scope.postSearchBean.postState.push(profile.state);
348                 if(profile.zipCodeSuffix==null)
349                         $scope.postSearchBean.postZipCode.push(profile.zipCode);
350                 else
351                         $scope.postSearchBean.postZipCode.push(profile.zipCode+'-'+profile.zipCodeSuffix);
352                 $scope.postSearchBean.postLocationClli.push(profile.locationClli);
353                 $scope.postSearchBean.postBusinessCountryCode.push(profile.businessCountryCode);
354                 $scope.postSearchBean.postBusinessCountryName.push(profile.businessCountryName);
355                 $scope.postSearchBean.postDepartment.push(profile.department);
356                 $scope.postSearchBean.postDepartmentName.push(profile.departmentName);
357                 $scope.postSearchBean.postBusinessUnit.push(profile.businessUnit);
358                 $scope.postSearchBean.postBusinessUnitName.push(profile.businessUnitName);
359                 $scope.postSearchBean.postJobTitle.push(profile.jobTitle);
360                 $scope.postSearchBean.postManagerAttuid.push(profile.managerAttuid);
361                 $scope.postSearchBean.postCommandChain.push(profile.commandChain);
362                 $scope.postSearchBean.postCompanyCode.push(profile.companyCode);
363                 $scope.postSearchBean.postCompany.push(profile.company);
364                 $scope.postSearchBean.postCostCenter.push(profile.costCenter);
365                 $scope.postSearchBean.postSiloStatus.push(profile.siloStatus);
366                 $scope.postSearchBean.postFinancialLocCode.push(profile.financialLocCode);
367         };
368                 
369         });     
370 </script>