SIMASSIGN_KKB1.jsp 33.8 KB
Newer Older
Thitichaipun Wutthisak committed
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 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
<%@page contentType="text/html; charset=UTF-8"%>
<%@page import="com.csc.library.utilities.CscCalendar,com.csc.library.entry.HelpEntry,com.csc.library.system.*"%>
<%@page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*,com.csc.library.utilities.*"  %>
<%@page import="java.util.Calendar,java.util.GregorianCalendar,java.util.HashMap"%>
<jsp:useBean id="SIMASSIGN_KKB1" class="com.csc.library.system.Task" scope="page" />
<jsp:useBean id="AS_ASSIGN_LIST" class="com.csc.library.system.Task" scope="page" /> 
<%
	CheckNull chkNull=new CheckNull();
	ThaiUtilities thatUtils = new ThaiUtilities();	

	SIMASSIGN_KKB1.setChannel(request,response);
	AS_ASSIGN_LIST.setChannel(request,response); 

	UIManager screen = (UIManager) SIMASSIGN_KKB1.process("SingleEntry","SIMASSIGN_KKB1"); 
	HelpEntry screenHelp = (HelpEntry) AS_ASSIGN_LIST.process("HelpEntry", "AS_ASSIGN_LIST");   
	
	String whereClause="";
	String qs_openwith = request.getParameter("__openwith");
	String qs_employeeid = request.getParameter("__employeeid");
	String qs_vote1id = request.getParameter("__vote1id");

	if(qs_openwith.equals("AS_ASSIGN_KKB")){
		//ยังไม่ลาออก และยังไม่เคย ถูกกำหนดให้เป็นผู้ Assign มาก่อน
		whereClause = " memployee.status in('A') "
							+" and memployee.employeeid not in (select employeeid from massign_kkb1 ) ";
	} else if(qs_openwith.equals("AS_VOTE1_KKB")){
		//ยังไม่ลาออก และยังไม่เคย ถูกกำหนดให้เป็นผู้ถูกโหวตมาก่อน
		//และไม่ใช่ผู้ Assign (ตัวเอง)
		 whereClause = " memployee.status in('A') "
							 +" and memployee.employeeid not in (select vote1id from mvote_kkb1 where employeeid='"+ qs_employeeid+"') "
							 +" and memployee.employeeid <> "+ qs_employeeid;

	}else if(qs_openwith.equals("AS_VOTE2_KKB")){
	    //ยังไม่ลาออก และยังไม่เคย ถูกกำหนดให้เป็นผู้โหวตมาก่อน
		//ตัวเอง และ บอสตัวเอง ถูก add ให้อนุมัติไปแล้ว ตอน add ผู้ถูกโหวต
		 whereClause = " memployee.status in('A') "
							 +" and memployee.employeeid not in (select vote2id from mvote_kkb2 where employeeid='"+ qs_employeeid+"' and vote1id='"+ qs_vote1id+"') ";
	}//end if 

	String curBu1Id ="";
	String curBu2Id = "";
	String curBu3Id = "";
	String curPositionId = "";
	String curEmployee_name = "";
	String curNickName = "";

	   if(request.getParameter("__cmd") != null && request.getParameter("__cmd").equals("search")) {
				if(request.getParameter("__mbu1_id")!=null && !request.getParameter("__mbu1_id").equals("")){
					 curBu1Id = " and memployee.bu1 ='" + request.getParameter("__mbu1_id")+"'";
				}//end if 
			
				if(request.getParameter("__mbu2_id")!=null && !request.getParameter("__mbu2_id").equals("")){
					 curBu2Id = " and memployee.bu2 ='" + request.getParameter("__mbu2_id")+"'";
				}//end if 

				if(request.getParameter("__mbu3_id")!=null && !request.getParameter("__mbu3_id").equals("")){
					 curBu3Id = " and memployee.bu3 ='" + request.getParameter("__mbu3_id")+"'";
				}//end if 

				if(request.getParameter("__positionid")!=null && !request.getParameter("__positionid").equals("")){
					 curPositionId = " and memployee.emp_position='" + request.getParameter("__positionid")+"'";
				}else{
					//ผู้โหวต ไม่ต้อง กรอง position
					 if(!qs_openwith.equals("AS_VOTE2_KKB")){
						curPositionId =" and memployee.emp_position between 'P08' and 'P16' ";
					}//end if 
				}//end if 

				if(request.getParameter("Employee_name")!=null && !request.getParameter("Employee_name").equals("")){
					 curEmployee_name = " and memployee.fname like'%" + 
						new String(request.getParameter("Employee_name").getBytes("ISO8859_1"),"UTF-8")+"%'";
				}//end if

				if(request.getParameter("NickName")!=null && !request.getParameter("NickName").equals("")){
					 curNickName = " and memployee.nickname like'%" + 
						new String(request.getParameter("NickName").getBytes("ISO8859_1"),"UTF-8")+"%'";
				}//end if

	  			whereClause+=curBu1Id+curBu2Id+curBu3Id+curPositionId+curEmployee_name+curNickName;			
	   }else{
		   //ผู้โหวต ไม่ต้อง กรอง position
		    if(!qs_openwith.equals("AS_VOTE2_KKB")){
				curPositionId =" and memployee.emp_position between 'P08' and 'P16' ";
			}//end if 
		   whereClause+=curPositionId;
	  }//end if 
	//out.print("whereClause is:"+ whereClause);
	screenHelp.getInquiry().setFilter(whereClause);
	screenHelp.setMaxLine(13);
	screenHelp.process();
	screenHelp.getInquiry().refresh();

	//out.print("getFilter is:"+ screenHelp.getInquiry().getFilter());
	//out.print("recCount is:"+ screenHelp.getInquiry().recCount());
    CscCalendar today = new CscCalendar();
    CscCalendar vote_date = new CscCalendar();

    String whereClauseMgroupVote = " status = '1' ";
 
	UProfile up = new UProfile(); 
	up =screen.getUProfile();
	HashMap param = new HashMap();

	DbInquiry inq = new InitialInquiry(up).getDbInquiry(); 
	inq.setSchemaName(up.getSchemaName());

	inq.setParam(param);
	inq.initMyTable("mgroup_vote", whereClauseMgroupVote, "");
	inq.setColumn("GROUP_QUESID,COMPANYID,VOTE_DATE");
	inq.refresh();
	int row = 1 ;
	while (inq.next()) {
		 vote_date = new CscCalendar(inq.getCurrentDbRecord().getString("VOTE_DATE")); 
	}//end while


/**=================================================
*nuiss edit 
*06/11/2551
*check relation with boss and employee
==================================================*/
//get bossList
	String whereClauseSupervisor = " employeeid = '"+qs_vote1id+"'";
	String bossList ="";
	DbInquiry inqSupervisor = new InitialInquiry(up).getDbInquiry(); 
	
	inqSupervisor.setSchemaName(up.getSchemaName());
	inqSupervisor.initMyTable("msupervisor", whereClauseSupervisor, "");
	inqSupervisor.setColumn("employeeid,supervisor");
	inqSupervisor.refresh();
	while (inqSupervisor.next()) {
		 bossList = inqSupervisor.getString("supervisor") ; 
	}//end while

//get subList
	String whereClauseSub = " supervisor like '%,"+qs_vote1id+",%'";
	String strSubList ="";
	String employeeid ="";
	String supervisorList="";
	DbInquiry inqSub = new InitialInquiry(up).getDbInquiry(); 

	inqSub.setSchemaName(up.getSchemaName());
	inqSub.initMyTable("msupervisor", whereClauseSub, "");
	inqSub.setColumn("employeeid,supervisor");
	inqSub.refresh();
	int rowCount = 0 ;
	while (inqSub.next()) {
		rowCount++;
		employeeid = inqSub.getString("EMPLOYEEID");
		supervisorList =inqSub.getString("SUPERVISOR");
		if(strSubList.equals("")){
			strSubList = employeeid+"#"+supervisorList;
		}else{
			strSubList += "@"+employeeid+"#"+supervisorList;
		}//end if
	}//end while
	//มันไม่มี subList (ไม่มีลูกน้อง)
	//ถ้าไม่ set ให้มัน ใน class จะ error เพราะ array out of bound
	if (rowCount==0){
		//default ค่าให้มันไป
		strSubList="UVWXYZ#,"+qs_vote1id+",";
	}//
	//out.print("<br><br>bossList  is:>>>>"+bossList);
	//out.print("<br><br>strSubList  is:>>>>"+strSubList);
//==================================================
%>
 
<html>
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<script type='text/javascript' src='../JS/SCREEN.js'></script>
<script type='text/javascript' src='../JS/DATEINPUT.js'></script>
<script type='text/javascript' src='../JS/VIEWCALENDAR.js'></script>
<script type='text/javascript' src='../JS/ICONSMENU.js'></script>
<script language='javascript'>setLang('<%=screen.getUProfile().get("lang")%>');</script>
<script language="javascript">getTitleName();</script>
<script language='javascript' src='../JS/HOTKEY.js'></script>
</head>
<body leftmargin="0" topmargin="0">
<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
<!--set QuertString ทุกครั้งเมื่อมัน submit ด้วย page ของมันเอง จาก search หรือ add-->
<form name="cscform" method="post" action="SIMASSIGN_KKB1.jsp?__openwith=<%=request.getParameter("__openwith")%>&__employeeid=<%=request.getParameter("__employeeid")%>&__vote1id=<%=request.getParameter("__vote1id")%>">

<!----------BEGIN CSC INITIAL ZONE ------------------------>
<%=screen.InitialVariable()%>
<!----------END CSC INITIAL ZONE -------------------------->

<!---------------- HIDDEN FIELD ZONE ---------------------->
	<!-- Single Use -->
	<input type="hidden" name="__notNull" value="<%=screen.getRequire()%>">	
	<!-- All Use -->
	<input type="hidden" name="__screen" value="SIMASSIGN_KKB1">
	<input type="hidden" name="__cmd" value="">
	<input type="hidden" name="__help" value="">
	<input type="hidden" name="__goPage" value="">
	<input type="hidden" name="__orderBy" value="">
	<input type="hidden" name="__helpReturn" value="">
	<input type="hidden" name="__helpName" value="">
	<input type="hidden" name="__pageCall" value="">
	<input type="hidden" name="__fixCon" value="<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("__fixCon")))%>">
	<input type="hidden" name="__calendar">
	<input type="hidden" name="__dateid" value="">
	<input type="hidden" name="__time0id" value="">
	<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
	<input type="hidden" name="__companyid" value="<%=screen.getUProfile().get("companyid")%>">

	<input type="hidden" name="__addItem" value="">
	<input type="hidden" name="__addItem_mvote_kkb1" value="">
	<input type="hidden" name="__addItem_mvote_kkb2" value="">

	<!--QueryString from Opener-->
	<input id='txtOpenWith' type='hidden' value='<%=request.getParameter("__openwith")%>'>
	<input id='txtEmployeeId' type='hidden' value='<%=request.getParameter("__employeeid")%>'>
	<input id='txtVote1Id' type='hidden' value='<%=request.getParameter("__vote1id")%>'>
	<!---------------- HIDDEN FIELD ZONE ---------------------->

	<script language="javascript">getInputFormatDate();</script>
	<script language="javascript">initToolTips();</script>   
	<script language="JavaScript" type="text/JavaScript">
  
		function goHelp(helpName,inputName){
			var helpReturn; 
			var fcon = document.cscform.__fixCon.value;
			with (document.cscform) {
				if(inputName=="__mbu1_id" ) {
					helpReturn="__mbu1_id:bu1id,__mbu1_tdesc:tdesc";
					if (!conMBU1.checked) conMBU1.checked = true;
					document.cscform.__fixCon.value ="";
				}else if(inputName=="__mbu2_id" ) {
					helpReturn="__mbu2_id:bu2id,__mbu2_tdesc:tdesc";
					if (!conMBU2.checked) conMBU2.checked = true;
					document.cscform.__fixCon.value ="";
				}else if(inputName=="__mbu3_id" ) {
					helpReturn="__mbu3_id:bu3id,__mbu3_tdesc:tdesc";
					if (!conMBU3.checked) conMBU3.checked = true;
					document.cscform.__fixCon.value ="";
				}else if(inputName=="__positionid" ) {
					helpReturn="__positionid:positionid,__position:tdesc";
					if (!conPosition.checked) conPosition.checked = true;

					//check condition with opener
					if(document.getElementById('txtOpenWith').value=="AS_ASSIGN_KKB"){
						document.cscform.__fixCon.value =" (positionid>='P08') ";
					}else if(document.getElementById('txtOpenWith').value=="AS_VOTE1_KKB"){
						document.cscform.__fixCon.value =" (positionid>='P08') ";
					}else if(document.getElementById('txtOpenWith').value=="AS_VOTE2_KKB"){
						document.cscform.__fixCon.value ="";
					}//end if 
					
				}//end if 
			}
			linkHelp_Return(helpName,helpReturn);
			document.cscform.__fixCon.value = fcon;
		}//end function 
 
		function checkAll(){
			 with(document.cscform){
					for(i=0;i<elements.length;i++){
						if(elements[i].type=="checkbox" &&
							elements[i].name != "conMBU1" && 
							elements[i].name != "conMBU2" && 
							elements[i].name != "conMBU3" && 
							elements[i].name != "conPosition" &&
							elements[i].name != "conEmployee" && 
							elements[i].name != "conNickName" )
							elements[i].checked=true;
					}//end for
				}//end with
		}//end function 
	 
		function decheckAll(){
			with(document.cscform){
				for(i=0;i<elements.length;i++){
					if(elements[i].type=="checkbox" &&
						elements[i].name != "conMBU1" &&
						elements[i].name != "conMBU2" &&
						elements[i].name != "conMBU3" &&
						elements[i].name != "conPosition" &&
						elements[i].name != "conEmployee" && 
						elements[i].name != "conNickName" )
						elements[i].checked=false;
				}//end for
			}//end with
		}//end function

		function addMulti(){
			chk = false;
			with(document.cscform){

				//initial value
				__addItem.value = "";
				__addItem_mvote_kkb1.value = "";
				__addItem_mvote_kkb2.value = "";

				for(i=0;i<elements.length;i++){
					if(	elements[i].name != "conMBU1" &&
						elements[i].name != "conMBU2" &&
						elements[i].name != "conMBU3" &&
						elements[i].name != "conPosition" &&
						elements[i].name != "conEmployee" && 
						elements[i].name != "conNickName" ){
						if (elements[i].checked) {
							chk = true;

							//set data 2 input for save แยกตาม page ที่เรียกมัน
							if(document.getElementById('txtOpenWith').value=="AS_ASSIGN_KKB"){
								//data index to javaclass [employeeid,bu1,bu2,position,bossid]

								if (__addItem.value != ""){
									__addItem.value = __addItem.value+","+elements[i].name;
								}else{
									__addItem.value = elements[i].name;
								}//end if
								//alert("__addItem is: " + __addItem.value);
							}else if(document.getElementById('txtOpenWith').value=="AS_VOTE1_KKB"){

								//data index to javaclass [vote1id,bu1,bu2,position,bossid,employeeid]
								if (__addItem_mvote_kkb1.value != ""){
									__addItem_mvote_kkb1.value = __addItem_mvote_kkb1.value+","+elements[i].name
																				 +":"+document.getElementById('txtEmployeeId').value;
								}else{
									__addItem_mvote_kkb1.value = elements[i].name+":"+document.getElementById('txtEmployeeId').value;
								}//end if
								//alert("__addItem_mvote_kkb1 is: " + __addItem_mvote_kkb1.value);
							}else if(document.getElementById('txtOpenWith').value=="AS_VOTE2_KKB"){

								//data index to javaclass [vote2id,bu1,bu2,position,bossid,employeeid,vote1id]
								if (__addItem_mvote_kkb2.value != ""){
									//ต้องเปลี่ยน sign split ใหม่ เพราะ ',' มันมีอยู่ใน data ของ  bossList กับ strSubList
									__addItem_mvote_kkb2.value = __addItem_mvote_kkb2.value+"~~"+elements[i].name
																				 +":"+document.getElementById('txtEmployeeId').value
																				 +":"+document.getElementById('txtVote1Id').value
																				 +":" + '<%=bossList%>' 
																				 +":" + "<%=strSubList%>";
								}else{
									__addItem_mvote_kkb2.value = elements[i].name
																				+":"+document.getElementById('txtEmployeeId').value
																				+":"+document.getElementById('txtVote1Id').value
																				+":" + '<%=bossList%>' 
																				+":" + "<%=strSubList%>";
								}//end if
								 //alert("__addItem_mvote_kkb2 is: " + __addItem_mvote_kkb2.value);
							}//end if 

						}//end if
					}//end if
				}//end for
				if (chk) {
					__cmd.value="save";
					submit();
				} else {
					//เมื่อไม่ระบุ รายการที่ต้องการ add
					if(document.getElementById('txtOpenWith').value=="AS_ASSIGN_KKB"){
						alert("กรุณาเลือกผู้ Assign ที่ต้องการเพิ่ม");	
					}else if(document.getElementById('txtOpenWith').value=="AS_VOTE1_KKB"){
						alert("กรุณาเลือกผู้ถูกโหวต ที่ต้องการเพิ่ม");	
					}else if(document.getElementById('txtOpenWith').value=="AS_VOTE2_KKB"){
						alert("กรุณาเลือกผู้โหวต ที่ต้องการเพิ่ม");	
					}//end if 
				}//end if 
			}//end with
		}//end function

		function refreshMain(){
			with(window.opener.cscform){
				__cmd.value = 'search';
				submit();	    
			}//end with

			//user will be close with himself
			//window.close();
		}//end function 


		function clearCon(strCon) {
			with (document.cscform){
				if (strCon=="__mbu1_id" && !conMBU1.checked) { __mbu1_id.value = ""; __mbu1_tdesc.value = ""; }
				if (strCon=="__mbu2_id" && !conMBU2.checked) { __mbu2_id.value = ""; __mbu2_tdesc.value = ""; }
				if (strCon=="__mbu3_id" && !conMBU3.checked) { __mbu3_id.value = ""; __mbu3_tdesc.value = ""; }
				if (strCon=="__positionid" && !conPosition.checked) { __positionid.value = ""; __position.value = ""; }
				if (strCon=="Employee_name" && !conEmployee.checked) { Employee_name.value = "";}
				if (strCon=="NickName" && !conNickName.checked) { NickName.value = "";}
			}//end with
		}//end function

		function nChkCondition(textBoxId,checkBoxId){
			var _value = document.getElementById(textBoxId).value;
				if (_value.toString()!=""){
					document.getElementById(checkBoxId).checked = true;
				}//end if 
		}//end function

		 function searchEmployee(){
			 
			with(document.cscform){ 
				//var whereClause=" 1=1 ";
				//ทุกครั้งที่ submit เก็บ whereClause เก่าไว้ด้วย
				var whereClause="<%=whereClause%>";
				
				var bu1 = document.getElementById('__mbu1_id').value;
				var bu2 = document.getElementById('__mbu2_id').value;
				var bu3 = document.getElementById('__mbu3_id').value;
				var position = document.getElementById('__positionid').value;
				var employee_name = document.getElementById('Employee_name').value;
				var nickname = document.getElementById('NickName').value;
				if(bu1!=""){
					whereClause+= " and bu1='" + bu1 +"'";
				}//end if 
				if(bu2!=""){
					whereClause+= " and bu2='" + bu2 +"'";
				}//end if 
				if(bu3!=""){
					whereClause+= " and bu3='" + bu3 +"'";
				}//end if 
				if(position!=""){
					whereClause+= " and emp_position='" + position +"'";
				}//end if 
				if(employee_name!=""){
					whereClause+= " and fname like '%" + employee_name +"%'";
				}//end if 
				if(nickname!=""){
					whereClause+= " and nickname like '%" + nickname +"%'";
				}//end if 
 
				//alert("in searchEmployee() whereClause is:"+ whereClause);
				document.cscform.__fixCon.value =whereClause;		

				__cmd.value="search"; 
				submit(); 

			}//end with
			
		}//end funtion 

		function checkedCheckBox(checkBoxId,isCheck){
			document.getElementById(checkBoxId).checked = isCheck;
		}//end function
</script>

	<br>
  	<table id='headerTab' cellpadding="0" cellspacing="0"  border="1"  class = "largest">
		<tr bgcolor="#3366CC">
		  <td  height="20" class="header" colspan="9">
		  <div id='nameTab'>
		  <script language="javascript">
					if(document.getElementById('txtOpenWith').value=="AS_ASSIGN_KKB"){
						document.getElementById('nameTab').innerText='SELECT_ASSIGN_LIST,';
						swapLang("SELECT ASSIGN LIST");
					}else if(document.getElementById('txtOpenWith').value=="AS_VOTE1_KKB"){
						document.getElementById('nameTab').innerText='SELECT_VOTE1_LIST,';
						swapLang("SELECT VOTE1 LIST");
					}else if(document.getElementById('txtOpenWith').value=="AS_VOTE2_KKB"){
						document.getElementById('nameTab').innerText='SELECT_VOTE2_LIST,';
						swapLang("SELECT VOTE2 LIST");
					}//end if 
		  </script>&nbsp;</div>
		  </td>
		</tr>
	 </table>

	<table border="0" cellpadding="0" cellspacing="0"  class = "largest">
	<tr><td>
	<table id='FindMemployee'  border="0" cellpadding="0" cellspacing="0" bgcolor="#666666" align='center'>
		<tr>
			<td colspan="1" align="right"><b><script language="javascript">swapLang("Condition");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="checkbox" NAME="conMBU1" ONCLICK="clearCon('__mbu1_id')"></td>
            <td align="right"><b><script language="javascript">swapLang("BU1");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="text"  id='__mbu1_id' NAME="__mbu1_id" SIZE="10" 
				VALUE = '<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("__mbu1_id")))%>' READONLY> 
              <A href="javascript: goHelp('MBU1HELP','__mbu1_id');"  onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('__group_quesid_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)">
			  <img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="SEARCH" name="__group_quesid_image" width="20" height="20" border="0" align="absmiddle" >
			  </a>	
              <INPUT TYPE="text" NAME="__mbu1_tdesc" SIZE="50" 
			  VALUE = '<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("__mbu1_tdesc")))%>' READONLY>
			</td>
	  </tr>
	  <tr>
			<td colspan="1" align="right"><b><script language="javascript">swapLang("Condition");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="checkbox" NAME="conMBU2"  ONCLICK="clearCon('__mbu2_id')"></td>
            <td align="right"><b><script language="javascript">swapLang("BU2");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="text"  id='__mbu2_id' NAME="__mbu2_id" SIZE="10" 
				VALUE = '<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("__mbu2_id")))%>' READONLY> 
              <A href="javascript: goHelp('MBU2HELP','__mbu2_id');"  onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('__group_quesid_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)">
			  <img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="SEARCH" name="__group_quesid_image" width="20" height="20" border="0" align="absmiddle" >
			  </a>	
              <INPUT TYPE="text"  NAME="__mbu2_tdesc" SIZE="50" 
			  VALUE = '<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("__mbu2_tdesc")))%>' READONLY>
			</td>
	  </tr>
	  <tr>
			<td colspan="1" align="right"><b><script language="javascript">swapLang("Condition");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="checkbox" NAME="conMBU3" ONCLICK="clearCon('__mbu3_id')"></td>
            <td align="right"><b><script language="javascript">swapLang("BU3");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="text"  id='__mbu3_id' NAME="__mbu3_id" SIZE="10" 
				VALUE = '<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("__mbu3_id")))%>' READONLY> 
              <A href="javascript: goHelp('MBU3HELP','__mbu3_id');"  onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('__group_quesid_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)">
			  <img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="SEARCH" name="__group_quesid_image" width="20" height="20" border="0" align="absmiddle" >
			  </a>	
              <INPUT TYPE="text"  NAME="__mbu3_tdesc" SIZE="50" 
			  VALUE = '<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("__mbu3_tdesc")))%>' READONLY>
			</td>
	  </tr>
	<tr>
		 <td colspan="1" align="right"><b><script language="javascript">swapLang("Condition");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="checkbox" id="conPosition" NAME="conPosition" ONCLICK="clearCon('__positionid')"></td>
            <td align="right"><b><script language="javascript">swapLang("Position");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="text"  id='__positionid' NAME="__positionid" SIZE="10" VALUE = '<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("__positionid")))%>' READONLY> 
              <A href="javascript: goHelp('MPOSITIONHELP','__positionid');"  onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('__group_quesid_image','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)">
			  <img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="SEARCH" name="__group_quesid_image" width="20" height="20" border="0" align="absmiddle" >
			  </a>	
              <INPUT TYPE="text"  NAME="__position" SIZE="50" 
			  VALUE = '<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("__position")))%>' READONLY>
			</td>
	</tr>
	<tr>
		 <td colspan="1" align="right"><b><script language="javascript">swapLang("Condition");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="checkbox" id="conEmployee" NAME="conEmployee" ONCLICK="clearCon('Employee_name')"></td>
            <td align="right"><b><script language="javascript">swapLang("Employee_name");</script>: &nbsp;</b></td>
            <td colspan='1'><input id='Employee_name' name='Employee_name' type='text' style='width:400px' 
			value='<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("Employee_name")))%>' onkeyup="nChkCondition('Employee_name','conEmployee')"></td>
	</tr>
	<tr>
		 <td colspan="1" align="right"><b><script language="javascript">swapLang("Condition");</script>: &nbsp;</b></td>
            <td><INPUT TYPE="checkbox" id="conNickName" NAME="conNickName" ONCLICK="clearCon('NickName')"></td>
            <td align="right"><b><script language="javascript">swapLang("Nick Name");</script>: &nbsp;</b></td>
			<td colspan='1'><input id='NickName' name='NickName' type='text' style='width:400px' 
			value='<%=chkNull.chkNullString(thatUtils.ASCII2Unicode(request.getParameter("NickName")))%>' onkeyup="nChkCondition('NickName','conNickName')"></td>
	</tr>
	</table> 
	</td></tr>
	<tr><td>
			<div align="center" >
					<a href="javascript:searchEmployee();"><img src="../IMAGES/BUTTON/SEARCH.gif" border="0"></a>
			</div>
	</td></tr>
	<tr><td class="blankspace" colspan="4">
		<!--Tab Page-->
			<div align="right">&lt;<%=screenHelp.getPageTag()%> &gt;&nbsp;</div> 
		<!--Tab Page-->
	</td></tr>
	<tr><td>
	<!--Display data from Table Memployee-->
 	<table id='tblMemployee' width="100%"  border="0" cellpadding="1" cellspacing="1" bgcolor="#666666" class='largest'>
	<thead>
		<tr>
			<td width="2%" class="row3"><div align="center"><B>
				<script language="javascript">swapLang("Select");</script></B></div>
			</td>
			<td width="3%" class="row3"><div align="center"><B>
			<script language="javascript">swapLang("Seq");</script></B></div>
			</td> 
			<td width="7%" class="row3">
				<div align="center"><B>
					<script language="javascript">
						if(document.getElementById('txtOpenWith').value=="AS_ASSIGN_KKB"){
							swapLang("ASSIGNID");
						}else if(document.getElementById('txtOpenWith').value=="AS_VOTE1_KKB"){
							swapLang("VOTE1ID");
						}else if(document.getElementById('txtOpenWith').value=="AS_VOTE2_KKB"){
							swapLang("VOTE2ID");
						}//end if 
					</script>
				</B></div>
			</td> 
			<td width="20%" class="row3"><div align="center"><B>
					<script language="javascript">
						if(document.getElementById('txtOpenWith').value=="AS_ASSIGN_KKB"){
							swapLang("Full Name Assign");
						}else if(document.getElementById('txtOpenWith').value=="AS_VOTE1_KKB"){
							swapLang("Full Name Vote1");
						}else if(document.getElementById('txtOpenWith').value=="AS_VOTE2_KKB"){
							swapLang("Full Name Vote2");
						}//end if 
					</script>
				</B></div>
			</td> 
			<td width="7%" class="row3"><div align="center"><B>
			<script language="javascript">swapLang("Nick Name");</script></B></div>
			</td> 
			<td width="20%" class="row3"><div align="center"><b>
			<script language="javascript">swapLang("BU1");</script></b></div></td>				
			<td width="20%" class="row3"><div align="center"><b>
			<script language="javascript">swapLang("BU2");</script></b></div></td>		
			<td width="20%" class="row3"><div align="center"><b>
			<script language="javascript">swapLang("Position");</script></b></div></td>
			<td width="10%" class="row3"><div align="center"><b>
			<script language="javascript">swapLang("Work Age");</script></b></div></td>	 
			<!--td>bossid</td-->
		</tr>
	</thead>
		<tbody>
		<%
			int i = 0;
			while(screenHelp.nextRec()){
				//check row over flow in page
				if(screenHelp.checkLinePage()) {
		 		
						String thWorkAge = screenHelp.getDataLabel("MEMPLOYEE","empworkages");
						String newWorkAge = thWorkAge.replace(" ","");
								  newWorkAge = newWorkAge.replace("ปี","/");
								  newWorkAge = newWorkAge.replace("เดือน","/");
								  newWorkAge = newWorkAge.replace("วัน","");
						String[] workage=  newWorkAge.split("/");

						String status = screenHelp.getDataLabel("MEMPLOYEE","STATUS");
						//อายุงานต้องมากกว่า หรือ เท่ากับ 6 เดือน  
						//ไปเอา mgroup_vote.vote_date มาเป็นตัวตั้ง แล้ว คำนวนว่า จนถึงวันที่ vote แล้วอายุงาน >= 6 เดือน ?
					
						CscCalendar emp_StartDate = new CscCalendar(screenHelp.getString("MEMPLOYEE","STARTDATE"));
	  
						Calendar startDate = new GregorianCalendar(today.getYear()
								,today.getMonth(),today.getDayOfWeek());
						
						Calendar endDate = new GregorianCalendar(vote_date.getYear()
								,vote_date.getMonth(),vote_date.getDayOfWeek());
						
						int[] dateSpan =new int[3];
						int workageAllow = 6;

						if((startDate.compareTo(endDate)) == 0){
							//out.print("startDate==endDate"); 
						}else if((startDate.compareTo(endDate))<0){
							dateSpan = today.getCountDMY(vote_date);
							//out.print("startDate < endDate " + (startDate.compareTo(endDate)) +  " diff " +dateSpan[1]+ " เดือน"); 
							workageAllow =(workageAllow-dateSpan[1]);
						}else if((startDate.compareTo(endDate))>0){
							//out.print("startDate > endDate "+(startDate.compareTo(endDate)) ); 
						}//end if 
		
						//out.print("workageAllow is: "+workageAllow);
						if( (Integer.parseInt(workage[0])>=1 || Integer.parseInt(workage[1]) >=workageAllow) && (status.equals("A")) ) {
						
							i++;
		%>
			<tr>	    					
				<td class="forborder">
					<div align="center">
						<input type="checkbox" name="<%=screenHelp.getString("EMPLOYEEID")%>:<%=screenHelp.getString("MEMPLOYEE","BU1")%>:<%=screenHelp.getString("MEMPLOYEE","BU2")%>:<%=screenHelp.getString("MEMPLOYEE","EMP_POSITION")%>:<%=screenHelp.getString("MEMPLOYEE","BOSSID")%>">
					</div>
				</td>
				<td class="forborder"><div align="center"><%=i%></div></td>
				<td class="forborder"><div align="center"><%=screenHelp.getString("EMPLOYEEID")%></div></td>
				<td class="forborder">
					<div align="center">
						<%=screenHelp.getString("MPREFIX","TDESC")+screenHelp.getString("MEMPLOYEE","FNAME")%>
						&nbsp;<%=screenHelp.getString("MEMPLOYEE","LNAME")%>
					</div>
				</td>
				<td class="forborder">
				<div align="center">
					<% 
						if(screenHelp.getString("MEMPLOYEE","NICKNAME").equals("")){
							out.print("&nbsp");
						  }else{
							 out.print( screenHelp.getString("MEMPLOYEE","NICKNAME"));
						  }//end if 
					%>
				</div>	
				</td>
				<td class="forborder">
				<div align="center">
					<% 
						if(screenHelp.getString("MBU1","TDESC").equals("")){
							out.print("&nbsp");
						  }else{
							 out.print( screenHelp.getString("MBU1","TDESC"));
						  }//end if 
					%>
				</div>	
				</td>
				<td class="forborder">
					<div align="center">
					<% 
						if(screenHelp.getString("MBU2","TDESC").equals("")){
							out.print("&nbsp");
						  }else{
							 out.print( screenHelp.getString("MBU2","TDESC"));
						  }//end if 
					%>
				</div>	
				</td> 
				<td class="forborder"><div align="center"><%=screenHelp.getString("MPOSITION","TDESC")%></div></td>
				<td class="forborder">
					<div align="center"> 
					 <%
						out.print(workage[0]+"/"+workage[1]);
					%>
					</div>
				</td>
				<!--td><%//=screenHelp.getString("MEMPLOYEE","STATUS")%></td-->
				<!--td><%//=screenHelp.getString("MEMPLOYEE","BOSSID")%></td-->
				<!--td><%//=screenHelp.getString("MEMPLOYEE","EMP_POSITION")%></td-->
			</tr>
		<%	
						}//end if 
				}//end if 
						if(screenHelp.outLinePage()) { 
							break; 
						}//end if 
			}//end while
		%>
		</tbody>
	</table>
</td></tr>
<tr><td>
	<div align='center'>
	<table>
	<tr bordercolor="0069B3">
		<td class="blankspace">
			<div align="center" >
				<a href="#" onClick="checkAll()"><img src="../IMAGES/BUTTON/SELECTALL.gif" border="0"></a>&nbsp;&nbsp;
				<a href="#" onClick="decheckAll()"><img src="../IMAGES/BUTTON/DESELECTALL.gif" border="0"></a>&nbsp;&nbsp;
				<a href="javascript:addMulti();"><img src="../IMAGES/BUTTON/ADD.gif" border="0"></a>&nbsp;&nbsp;
			</div>
		</td>
    </tr>
  </table>
  </div>
</td></tr>
<tr bordercolor="0069B3"> 
        <td class="bottom"></td>
 </tr>
</table>
<!--todo after submit with add-->
<% 
	if((request.getParameter("__cmd")!=null)&&(request.getParameter("__cmd").equals("add")||request.getParameter("__cmd").equals("save"))) {
%>
	<script language="javascript">refreshMain();</script>
<%
	}
%>
<!--todo after submit with search-->
<% 
	//if((request.getParameter("__cmd")!=null)&&(request.getParameter("__cmd").equals("search"))) {
	//checked checkbox whereclause
%>
		<%if(request.getParameter("__mbu1_id")!=null && !request.getParameter("__mbu1_id").equals("")){%>
				<script language="javascript">checkedCheckBox("conMBU1",true);</script>
		<%}//end if %>
		<%if(request.getParameter("__mbu2_id")!=null && !request.getParameter("__mbu2_id").equals("")){%>
				<script language="javascript">checkedCheckBox("conMBU2",true);</script>
		<%}//end if %>
		<%if(request.getParameter("__mbu3_id")!=null && !request.getParameter("__mbu3_id").equals("")){%>
				<script language="javascript">checkedCheckBox("conMBU3",true);</script>
		<%}//end if %>
		<%if(request.getParameter("__positionid")!=null && !request.getParameter("__positionid").equals("")){%>
				<script language="javascript">checkedCheckBox("conPosition",true);</script>
		<%}//end if %>
		<%if(request.getParameter("Employee_name")!=null && !request.getParameter("Employee_name").equals("")){%>
				<script language="javascript">checkedCheckBox("conEmployee",true);</script>
		<%}//end if %>
		<%if(request.getParameter("NickName")!=null && !request.getParameter("NickName").equals("")){%>
				<script language="javascript">checkedCheckBox("conNickName",true);</script>
		<%}//end if %>
<%
	//}//end if 
%>
<!--todo after submit with search-->
<!----------BEGIN CSC ENDING ZONE ------------------------>

<%=screen.endJSP()%>

<!----------END CSC ENDING ZONE -------------------------->
</form>
</body>
</html>