MutiResourceSelect.jsp 25.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*" %>
<%@ page import="weaver.file.Prop,weaver.general.GCONST" %>

<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@page import="weaver.hrm.User"%>
<%@page import="weaver.systeminfo.SystemEnv"%> 
<%@ page import="weaver.file.FileUpload" %>
<%@ page import="weaver.conn.ConnectionPool" %>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="DepartmentComInfo" class="weaver.hrm.company.DepartmentComInfo" scope="page" />
<jsp:useBean id="SubCompanyComInfo" class="weaver.hrm.company.SubCompanyComInfo" scope="page" />
<jsp:useBean id="RoleComInfo" class="weaver.hrm.roles.RolesComInfo" scope="page" />
<jsp:useBean id="JobTitlesComInfo" class="weaver.hrm.job.JobTitlesComInfo" scope="page" />
<%@ include file="MobileInit.jsp"%>
<%

String tabid = Util.null2String(fu.getParameter("tabid"));
String nodeid = Util.null2String(fu.getParameter("nodeid"));
String mode=Prop.getPropValue(GCONST.getConfigFile() , "authentic");
String companyid = Util.null2String(fu.getParameter("companyid"));
String subcompanyid = Util.null2String(fu.getParameter("subcompanyid"));
String departmentid = Util.null2String(fu.getParameter("departmentid"));
String groupid = Util.null2String(fu.getParameter("groupid"));
boolean isoracle = RecordSet.getDBType().equals("oracle");

if(tabid.equals("")) tabid="0";

String check_per = Util.null2String(fu.getParameter("resourceids"));
if(check_per.equals(",")){
	check_per = "";
}
String resourceids = "" ;
String resourcenames ="";
//如果页面传过来的是自定义组id,而不是resourceids,则把group分解成resourceids
    String initgroupid=Util.null2String(fu.getParameter("initgroupid"));

    if(!initgroupid.equals("")){
        check_per="";
        RecordSet.executeSql("select userid from hrmgroupmembers where groupid="+initgroupid) ;
        String userid;
        while(RecordSet.next()){
            userid=RecordSet.getString("userid");
            if(check_per.equals(""))
            check_per+=userid;
            else
            check_per=check_per+","+userid;
        }
    }
 String coworkid= Util.null2String(fu.getParameter("coworkid"));
  if(!coworkid.equals("")){
        check_per="";
        RecordSet.executeSql("select coworkers from cowork_items where id="+coworkid) ;
        String userid;
        while(RecordSet.next()){
            userid=RecordSet.getString("coworkers");
            if(check_per.equals(""))
            check_per+=userid;
            else
            check_per=check_per+","+userid;
        }
    }
  String cowtypeid = Util.null2String(fu.getParameter("cowtypeid"));
  if(!cowtypeid.equals("")){
      check_per="";
      RecordSet.executeSql("select members from cowork_types where id="+cowtypeid) ;
      String userid;
      while(RecordSet.next()){
          userid=RecordSet.getString("members");
          if(check_per.equals(""))
          check_per+=userid;
          else
          check_per=check_per+","+userid;
      }
  }
  
  String workID= Util.null2String(fu.getParameter("workID"));
  if(!workID.equals("")){
        check_per="";
        RecordSet.executeSql("select resourceID from WorkPlan where id="+workID) ;
        String userid;
        while(RecordSet.next()){
            userid=RecordSet.getString("resourceID");
            if(check_per.equals(""))
            check_per+=userid;
            else
            check_per=check_per+","+userid;
        }
    }
if(!check_per.equals("")){
	//if(check_per.substring(0,1).equals(","))check_per = check_per.substring(1);
	//if(check_per.substring(check_per.length()-1).equals(","))check_per = check_per.substring(0,check_per.length()-1);
	if(check_per.substring(0,1).equals(","))check_per = check_per.substring(1);
	if(check_per.substring(0,1).equals(","))check_per = check_per.substring(1);
	if(check_per.substring(check_per.length()-1).equals(","))check_per = check_per.substring(0,check_per.length()-1);
	if(check_per.substring(check_per.length()-1).equals(","))check_per = check_per.substring(0,check_per.length()-1);
	try {
		String strtmp = "select id,lastname,departmentid from HrmResource where id in (" + check_per + ")";
		if (!initgroupid.equals(""))
			strtmp = "select id,lastname,departmentid from HrmResource where id in (select userid from hrmgroupmembers where groupid=" + initgroupid + ")";

	if("jc".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype()) || "gs".equalsIgnoreCase(ConnectionPool.getInstance().getOrgindbtype())){
		strtmp = "select id,lastname,departmentid from HrmResource where exists  (select 1  from cowork_items where id="+coworkid+" and instr(coworkers,','||hrmresource.id||',',1,1)>0 )";
	}
	else if(!coworkid.equals("")&&isoracle){
      strtmp = "select id,lastname,departmentid from HrmResource where exists  (select 1  from cowork_items where id="+coworkid+" and dbms_lob.instr(coworkers,','||hrmresource.id||',',1,1)>0 )"; 
	}
	//System.out.print(strtmp);
    RecordSet.executeSql(strtmp);
	Hashtable ht = new Hashtable();
	//boolean ifhave=false;
	while(RecordSet.next()){
		//ifhave=true;
        String department = Util.toScreen(RecordSet.getString("departmentid"),user.getLanguage());
                        String mark=DepartmentComInfo.getDepartmentmark(department);

                        if(mark.length()>6)
                        mark=mark.substring(0,6);
                        int length=mark.getBytes().length;
                        if(length<12){
                            for(int i=0;i<12-length;i++){
                              mark+=" ";
                            }
                        }
                        String subcid=DepartmentComInfo.getSubcompanyid1(department);
                        String subc= SubCompanyComInfo.getSubCompanyname(subcid);
                        String lastname=RecordSet.getString("lastname");
                        length=lastname.getBytes().length;
                        if(length<10){
                            for(int i=0;i<10-length;i++){
                              lastname+=" ";
                            }
                        }
                        lastname=lastname+" | "+mark+" | "+subc;
        ht.put(RecordSet.getString("id"),lastname);
		/*
		if(check_per.indexOf(","+RecordSet.getString("id")+",")!=-1){

				resourceids +="," + RecordSet.getString("id");
				resourcenames += ","+RecordSet.getString("lastname");
		}
		*/
	}
    strtmp = "select id,lastname from HrmResourcemanager where id in ("+check_per+")";
	RecordSet.executeSql(strtmp);
	while(RecordSet.next()){
		
                        String lastname=RecordSet.getString("lastname");
                        int length=lastname.getBytes().length;
                        if(length<10){
                            for(int i=0;i<10-length;i++){
                              lastname+=" ";
                            }
                        }
                        lastname=lastname;
        ht.put(RecordSet.getString("id"),lastname);
		
	}
	StringTokenizer st = new StringTokenizer(check_per,",");

	while(st.hasMoreTokens()){
		String s = st.nextToken();
		resourceids +=","+s;
		resourcenames += ","+Util.StringReplace(ht.get(s).toString(),",",",");
	}
	}catch(Exception e){
		resourceids="";
		resourcenames="";
	}
}



Calendar today = Calendar.getInstance();
String currentdate = Util.add0(today.get(Calendar.YEAR), 4) +"-"+
				 Util.add0(today.get(Calendar.MONTH) + 1, 2) +"-"+
				 Util.add0(today.get(Calendar.DAY_OF_MONTH), 2) ;

String lastname = Util.null2String(fu.getParameter("lastname"));
String resourcetype = Util.null2String(fu.getParameter("resourcetype"));
String resourcestatus = Util.null2String(fu.getParameter("resourcestatus"));
String jobtitle = Util.null2String(fu.getParameter("jobtitle"));
 //departmentid = Util.null2String(fu.getParameter("departmentid"));
String sqlwhere = Util.null2String(fu.getParameter("sqlwhere"));
String status = Util.null2String(fu.getParameter("status"));
String firstname = Util.null2String(fu.getParameter("firstname"));
String seclevelto=Util.fromScreen(fu.getParameter("seclevelto"),user.getLanguage());    
String roleid = Util.null2String(fu.getParameter("roleid"));

if(tabid.equals("0")&&departmentid.equals("")&&sqlwhere.equals("")) departmentid=user.getUserDepartment()+"";

if(departmentid.equals("0"))    departmentid="";

if(subcompanyid.equals("0"))    subcompanyid="";

/*if(resourcestatus.equals(""))   resourcestatus="0" ;
if(resourcestatus.equals("-1"))   resourcestatus="" ;*/
if(status.equals("-1")) status = "";
int ishead = 0;
if(!sqlwhere.equals("")) ishead = 1;
if(!lastname.equals("")){
	if(ishead==0){
		ishead = 1;
		sqlwhere += " where lastname like '%" + Util.fromScreen2(lastname,user.getLanguage()) +"%' ";
	}
	else
		sqlwhere += " and lastname like '%" + Util.fromScreen2(lastname,user.getLanguage()) +"%' ";
}
if(!firstname.equals("")){
	if(ishead==0){
		ishead = 1;
		sqlwhere += " where firstname like '%" + Util.fromScreen2(firstname,user.getLanguage()) +"%' ";
	}
	else
		sqlwhere += " and firstname like '%" + Util.fromScreen2(firstname,user.getLanguage()) +"%' ";
}
if(!seclevelto.equals("")){
	if(ishead==0){
		ishead = 1;
		sqlwhere += " where HrmResource.seclevel <= '"+ seclevelto + "' ";
	}
	else
		sqlwhere += " and HrmResource.seclevel <= '"+ seclevelto + "' ";
}
if(!resourcetype.equals("")){
	if(ishead==0){
		ishead = 1;
		sqlwhere += " where resourcetype = '"+ resourcetype + "' ";
	}
	else
		sqlwhere += " and resourcetype = '"+ resourcetype + "' ";
}

if(!jobtitle.equals("")){
	if(ishead==0){
		ishead = 1;
		sqlwhere += " where jobtitle in(select id from HrmJobTitles where jobtitlename like '%" + Util.fromScreen2(jobtitle,user.getLanguage()) +"%') ";
	}
	else
		sqlwhere += " and jobtitle in(select id from HrmJobTitles where jobtitlename like '%" + Util.fromScreen2(jobtitle,user.getLanguage()) +"%') ";
}
if(!departmentid.equals("")){
	if(ishead==0){
		ishead = 1;
		sqlwhere += " where departmentid =" + departmentid +" " ;
	}
	else
		sqlwhere += " and departmentid =" + departmentid +" " ;
}

if(departmentid.equals("")&&!subcompanyid.equals("")){
	if(ishead==0){
		ishead = 1;
		sqlwhere += " where subcompanyid1 =" + subcompanyid +" " ;
	}
	else
		sqlwhere += " and subcompanyid1 =" + subcompanyid +" " ;
}
if(!status.equals("")&&!status.equals("9")){
	if(ishead==0){
		ishead = 1;
		sqlwhere += " where status =" + status +" " ;
	}
	else
		sqlwhere += " and status =" + status +" " ;
}
if(status.equals("")){
	if(ishead==0){
		ishead = 1;
		sqlwhere += " where (status =0 or status = 1 or status = 2 or status = 3) " ;
	}
	else
		sqlwhere += " and (status =0 or status = 1 or status = 2 or status = 3) ";
}
 if(!roleid.equals("")){
        if(ishead==0){
            ishead = 1;
            sqlwhere += " where  HrmResource.ID in (select t1.ResourceID from hrmrolemembers t1,hrmroles t2 where t1.roleid = t2.ID and t2.ID="+roleid+" ) " ;
        }
        else
            sqlwhere += " and    HrmResource.ID in (select t1.ResourceID from hrmrolemembers t1,hrmroles t2 where t1.roleid = t2.ID and t2.ID="+roleid+" ) " ;
    }

String sqlstr = "";
if(mode==null||!mode.equals("ldap")){
	 sqlstr = "select HrmResource.id,lastname,departmentid,jobtitle "+
    "from HrmResource " + sqlwhere+" order by dsporder,lastname";
if(tabid.equals("0")&&!companyid.equals("")){
	sqlstr="select  id,lastname,departmentid,jobtitle  from hrmresource where (status =0 or status = 1 or status = 2 or status = 3) and loginid is not null ";
	if(!isoracle) sqlstr+="and loginid<>''";
	sqlstr+=" order by dsporder,lastname";
}
if(tabid.equals("0")&&!subcompanyid.equals("")){
	sqlstr="select  id,lastname,departmentid,jobtitle  from hrmresource where (status =0 or status = 1 or status = 2 or status = 3) and loginid is not null ";
	if(!isoracle) sqlstr+="and loginid<>''";
	sqlstr+=" and subcompanyid1="+Util.getIntValue(subcompanyid)+" order by dsporder,lastname";
}
if(tabid.equals("0")&&!departmentid.equals("")){
	sqlstr="select  id,lastname,departmentid,jobtitle  from hrmresource where (status =0 or status = 1 or status = 2 or status = 3) and loginid is not null ";
	if(!isoracle) sqlstr+="and loginid<>''";
	sqlstr+=" and departmentid="+Util.getIntValue(departmentid)+" order by dsporder,lastname";
}
}else{
	if(!isoracle) sqlwhere+="and loginid<>''";
	 sqlstr = "select HrmResource.id,lastname,departmentid,jobtitle "+
    "from HrmResource " + sqlwhere+" and loginid is not null order by dsporder,lastname";
if(tabid.equals("0")&&!departmentid.equals("")){
sqlstr="select  id,lastname,departmentid,jobtitle  from hrmresource where (status =0 or status = 1 or status = 2 or status = 3) and loginid is not null ";
if(!isoracle) sqlstr+="and loginid<>''";
sqlstr+=" and departmentid="+Util.getIntValue(departmentid)+" order by dsporder,lastname";
}else if(tabid.equals("0")&&!subcompanyid.equals("")){
sqlstr="select  id,lastname,departmentid,jobtitle  from hrmresource where (status =0 or status = 1 or status = 2 or status = 3) and loginid is not null ";
if(!isoracle) sqlstr+="and loginid<>''";
sqlstr+=" and subcompanyid1="+Util.getIntValue(subcompanyid)+" order by dsporder,lastname";
}else if(tabid.equals("0")&&!companyid.equals("")){
sqlstr="select  id,lastname,departmentid,jobtitle  from hrmresource where (status =0 or status = 1 or status = 2 or status = 3) and loginid is not null ";
if(!isoracle) sqlstr+="and loginid<>''";
sqlstr+=" order by dsporder,lastname";
}


//if(!isoracle) sqlwhere+="and account<>''";
//	 sqlstr = "select HrmResource.id,lastname,departmentid,jobtitle "+
//    "from HrmResource " + sqlwhere+" and account is not null order by dsporder,lastname";
//if(tabid.equals("0")&&!departmentid.equals("")){
//sqlstr="select  id,lastname,departmentid,jobtitle  from hrmresource where (status =0 or status = 1 or status = 2 or status = 3) and account is not null ";
//if(!isoracle) sqlstr+="and account<>''";
//sqlstr+=" and departmentid="+Util.getIntValue(departmentid)+" order by dsporder,lastname";
//}else if(tabid.equals("0")&&!subcompanyid.equals("")){
//sqlstr="select  id,lastname,departmentid,jobtitle  from hrmresource where (status =0 or status = 1 or status = 2 or status = 3) and account is not null ";
//if(!isoracle) sqlstr+="and account<>''";
//sqlstr+=" and subcompanyid1="+Util.getIntValue(subcompanyid)+" order by dsporder,lastname";
//}else if(tabid.equals("0")&&!companyid.equals("")){
//sqlstr="select  id,lastname,departmentid,jobtitle  from hrmresource where (status =0 or status = 1 or status = 2 or status = 3) and account is not null ";
//if(!isoracle) sqlstr+="and account<>''";
//sqlstr+=" order by dsporder,lastname";
//}
}

if(tabid.equals("1")&&!groupid.equals("")){
	sqlstr="select t1.id,t1.lastname,t1.departmentid,t1.jobtitle from hrmresource t1,HrmGroupMembers t2 where t1.id=t2.userid and t2.groupid="+groupid+" order by t1.dsporder,t1.lastname";
	}
//add by alan for td:10343
boolean isInit = Util.null2String(fu.getParameter("isinit")).equals("");//是否点击过搜索
if((tabid.equals("2") && isInit) ||(tabid.equals("0") && nodeid.equals(""))) sqlstr = "select HrmResource.id,lastname,departmentid,jobtitle from HrmResource WHERE 1=2";
%>

<HTML><HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<LINK REL=stylesheet type=text/css HREF=/css/Weaver_wev8.css>
<script type='text/javascript' src='/js/jquery/jquery_wev8.js'></script>
</HEAD>
<BODY style="padding: 0px;margin: 0px;">
	
<table width=100% border="0" cellspacing="0" cellpadding="0" style="padding: 0px;margin: 0px;">

<tr>
  <td align="center" valign="top" width="45%">
	
			                <select size="13" name="from" multiple="true" style="width:100%" class="InputStyle" onclick="blur1($('select[name=srcList]')[0])" onkeypress="checkForEnter($('select[name=from]')[0],$('select[name=srcList]')[0])" ondblclick="one2two($('select[name=from]')[0],$('select[name=srcList]')[0])">
				             </select>
		      <script>
      <%
					RecordSet.executeSql(sqlstr);
					while(RecordSet.next()){
						String ids = RecordSet.getString("id");
						String firstnames = Util.toScreen(RecordSet.getString("firstname"),user.getLanguage());
						String lastnames = Util.toScreen(RecordSet.getString("lastname"),user.getLanguage());
                        int length=lastnames.getBytes().length;
                        if(length<10){
                            for(int i=0;i<10-length;i++){
                              lastnames+=" ";
                            }
                        }

                        String department = Util.toScreen(RecordSet.getString("departmentid"),user.getLanguage());
                        String mark=DepartmentComInfo.getDepartmentmark(department);

                        if(mark.length()>6)
                        mark=mark.substring(0,6);
                        length=mark.getBytes().length;
                        if(length<12){
                            for(int i=0;i<12-length;i++){
                              mark+=" ";
                            }
                        }
                        String subcid=DepartmentComInfo.getSubcompanyid1(department);
                        String subc= SubCompanyComInfo.getSubCompanyname(subcid);
                        lastnames=lastnames+" | "+mark+" | "+subc;
                        lastnames = lastnames.replace("'","\\'").replace("\"","\\\"");
                        %>

                          document.all("from").options.add(new Option('<%=lastnames%>','<%=ids%>'));


						<%}%>


                      </script>
		
  </td>
  
  <td align="center" width="10%">
				<img src="/mobile/plugin/browser/images/arrow_u_wev8.gif" style="cursor:pointer" title="<%=SystemEnv.getHtmlLabelName(15084,user.getLanguage())%>" onclick="javascript:upFromList();">
				<br>
				<img src="/mobile/plugin/browser/images/arrow_left_wev8.gif" style="cursor:pointer" title="<%=SystemEnv.getHtmlLabelName(456,user.getLanguage())%>" onClick="javascript:one2two($('select[name=from]')[0],$('select[name=srcList]')[0]);">
				<br>
				<img src="/mobile/plugin/browser/images/arrow_right_wev8.gif"  style="cursor:pointer" title="<%=SystemEnv.getHtmlLabelName(91,user.getLanguage())%>" onclick="javascript:two2one($('select[name=from]')[0],$('select[name=srcList]')[0]);">				
				<br>
				<img src="/mobile/plugin/browser/images/arrow_left_all_wev8.gif" style="cursor:pointer" title="<%=SystemEnv.getHtmlLabelName(17025,user.getLanguage())%>" onClick="javascript:removeAll($('select[name=from]')[0],$('select[name=srcList]')[0]);">
				<br>				
				<img src="/mobile/plugin/browser/images/arrow_right_all_wev8.gif"  style="cursor:pointer" title="<%=SystemEnv.getHtmlLabelName(16335,user.getLanguage())%>" onclick="javascript:removeAll($('select[name=srcList]')[0],$('select[name=from]')[0]);">				
				<br>
				<img src="/mobile/plugin/browser/images/arrow_d_wev8.gif"   style="cursor:pointer" title="<%=SystemEnv.getHtmlLabelName(15085,user.getLanguage())%>" onclick="javascript:downFromList();">
  </td>
  <td align="center" valign="top" width="45%">
				<select size="13" name="srcList"  multiple="true" style="width:100%" class="InputStyle" onclick="blur1($('select[name=from]')[0])"
				onkeypress="checkForEnter($('select[name=srcList]')[0],$('select[name=from]')[0])" ondblclick="two2one($('select[name=from]')[0],$('select[name=srcList]')[0])">
					
					
				</select>
  </td>
		
</tr>
<tr>
<td height="5" colspan=3></td>
</tr>
<tr>
     <td align="center" valign="bottom" colspan=3>
     
        <BUTTON class=btnSearch onclick="btnsub_onclick();" accessKey=S <%if(!tabid.equals("2")){%>style="display:none"<%}%> id=btnsub><U>S</U>-<%=SystemEnv.getHtmlLabelName(197,user.getLanguage())%></BUTTON>
     
	<BUTTON class=btn accessKey=O  id=btnok onclick="btnok_onclick();"><U>O</U>-<%=SystemEnv.getHtmlLabelName(826,user.getLanguage())%></BUTTON>
	<BUTTON class=btn accessKey=2  id=btnclear onclick="btnclear_onclick();"><U>2</U>-<%=SystemEnv.getHtmlLabelName(311,user.getLanguage())%></BUTTON>
        <BUTTON class=btnReset accessKey=T  id=btncancel onclick="btncancel_onclick();";><U>T</U>-<%=SystemEnv.getHtmlLabelName(201,user.getLanguage())%></BUTTON>
     </td>
</tr>
</TABLE>
<!--########//Shadow Table End########-->

<script language="javascript">
var resourceids = "<%=resourceids%>"
var resourcenames = "<%=resourcenames%>"

//Load
var resourceArray = new Array();
for(var i =1;i<resourceids.split(",").length;i++){
	if(resourceids.split(",")[i]!=0)
	resourceArray[i-1] = resourceids.split(",")[i]+"~"+resourcenames.split(",")[i];
	//alert(resourceArray[i-1]);
}

loadToList();
function loadToList(){
	var selectObj = $("select[name=srcList]")[0];
	for(var i=0;i<resourceArray.length;i++){
		addObjectToSelect(selectObj,resourceArray[i]);
	}
	
}


function addObjectToSelect(obj,str){
	//alert(obj.tagName+"-"+str)
	val = str.split("~")[0];
	txt = str.split("~")[1];
	obj.options.add(new Option(txt,val));
	
}


init($("select[name=from]")[0],$("select[name=srcList]")[0])



function upFromList(){
	var destList  = $("select[name=srcList]")[0];
	var len = destList.options.length;
	for(var i = 0; i <= (len-1); i++) {
		if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
			if(i>0 && destList.options[i-1] != null){
				fromtext = destList.options[i-1].text;
				fromvalue = destList.options[i-1].value;
				totext = destList.options[i].text;
				tovalue = destList.options[i].value;
				destList.options[i-1] = new Option(totext,tovalue);
				destList.options[i-1].selected = true;
				destList.options[i] = new Option(fromtext,fromvalue);		
			}
      }
   }
   reloadResourceArray();
}


function deleteFromList(){
	var destList  = $("select[name=srcList]")[0];
	var len = destList.options.length;
	for(var i = (len-1); i >= 0; i--) {
	if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
	destList.options[i] = null;
		  }
	}
	reloadResourceArray();
}
function removeAll(from,to){
	
	var len = from.options.length;
	for(var i = 0; i < len; i++) {
	to_len=to.options.length
	txt=from.options[i].text
	val=from.options[i].value
	to.options[to_len]=new Option(txt,val)	  
	}
	
	for(var i = len; i>=0; i--) {
	from.options[i]=null	  
	}
	
	reloadResourceArray();
}
function downFromList(){
	var destList  = $("select[name=srcList]")[0];
	var len = destList.options.length;
	for(var i = (len-1); i >= 0; i--) {
		if ((destList.options[i] != null) && (destList.options[i].selected == true)) {
			if(i<(len-1) && destList.options[i+1] != null){
				fromtext = destList.options[i+1].text;
				fromvalue = destList.options[i+1].value;
				totext = destList.options[i].text;
				tovalue = destList.options[i].value;
				destList.options[i+1] = new Option(totext,tovalue);
				destList.options[i+1].selected = true;
				destList.options[i] = new Option(fromtext,fromvalue);		
			}
      }
   }
   reloadResourceArray();
}
//reload resource Array from the List
function reloadResourceArray(){
	resourceArray = new Array();
	var destList = $("select[name=srcList]")[0];
	for(var i=0;i<destList.options.length;i++){
		resourceArray[i] = destList.options[i].value+"~"+destList.options[i].text ;
	}
	
}

//xiaofeng
function one2two(m1, m2)
{  
    // add the selected options in m1 to m2
    m1len = m1.length ;
    for ( i=0; i<m1len ; i++){
        if (m1.options[i].selected == true ) {
            m2len = m2.length;
            m2.options[m2len]= new Option(m1.options[i].text, m1.options[i].value);
        }
    }

reloadResourceArray()

	// remove all the selected options from m1 (because they have already been added to m2)	
	j = -1;
    for ( i = (m1len -1); i>=0; i--){
        if (m1.options[i].selected == true ) {
            m1.options[i] = null;
			j = i;
        }
    }
	
	if (j == -1)
		return;
		
	// move focus to the next item
	if (m1.length <= 0)
		return;
		
	if ((j < 0) || (j > m1.length))
		return;
		
	if (j == 0)
		m1.options[j].selected = true;
	else if (j == m1.length)
		m1.options[j-1].selected = true
	else
		m1.options[j].selected = true;


}

function two2one(m1, m2)
{
   one2two(m2,m1);
   reloadResourceArray();
}

function blur1(m){
for(i=0;i<m.length;i++){
m.options[i].selected=false
}
}

function checkForEnter(m1, m2) {
 
   var charCode =  event.keyCode;
   if (charCode == 13) {
      
      one2two(m1, m2);
   }
   return false;
}

function init(m1,m2){
for(i=0;i<m2.length;i++){
ids=m2.options[i].value
for(j=0;j<m1.length;j++){
if(m1.options[j].value==ids){
m1.options[j]=null
break
}
}
}

}

function setResourceStr(){
	
	var resourceids1 =""
        var resourcenames1 = ""
        
	for(var i=0;i<resourceArray.length;i++){
		resourceids1 += ","+resourceArray[i].split("~")[0] ;
		
		resourcenames1 += ","+resourceArray[i].split("~")[1].replace(/,/g,",") ;
	}
	resourceids=resourceids1
	resourcenames=resourcenames1
	
}
function replaceStr(){
    var re=new RegExp("[ ]*[|][^|]*[|]","g")
    resourcenames=resourcenames.replace(re,"|")
    re=new RegExp("[|][^,]*","g")
    resourcenames=resourcenames.replace(re,"")   
}
function btnok_onclick(){

	 setResourceStr();
     replaceStr();
     if(resourceids.length>0)
        resourceids=resourceids.substr(1);
     if(resourcenames.length>0)
        resourcenames=resourcenames.substr(1);  
     window.parent.parent.returnValue = {id:resourceids,name:resourcenames};
     window.parent.parent.close();
	
}
function btnclear_onclick(){
	window.parent.parent.returnValue = {id:"",name:""};
     window.parent.parent.close();
}
function btnsub_onclick(){
	//window.parent.parent.frame1.SearchForm.btnsub.click();
	/*
		var curDoc;
		if(document.all){
			curDoc=window.parent.frames["frame1"].document
		}
		else{
			curDoc=window.parent.document.getElementById("frame1").contentDocument	
		}
		$(curDoc).find("#btnsub")[0].click();
    */
    jQuery("#frame1",window.parent.document)[0].contentWindow.btnsub_onclick();
}
function btncancel_onclick(){
	 window.parent.parent.close();
}
</script>


</BODY>
</HTML>