MANPOWER_APP.jsp 49.6 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 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.system.*,com.csc.library.utilities.*,com.csc.library.session.*,com.csc.library.components.*,com.csc.library.report.*,java.util.*,java.text.DecimalFormat,java.math.BigDecimal,com.csc.library.database.DataSet;"%>
<jsp:useBean id="MANPOWER" scope="page" class="com.csc.library.system.Task" />


<html ng-app="myHR">
<%
	CheckNull chk = new CheckNull();
	CscCalendar cs = new CscCalendar();

	MANPOWER.setChannel(request ,response);
    HelpEntry screen = (HelpEntry) MANPOWER.process("HelpEntry", "MANPOWER_BUD_DATAHELP");
	screen.process();
	//initial value
	String thisdate = cs.getYYYYMMDD();
	String language = screen.getUProfile().get("lang");
	String cmd = chk.chkNullString(request.getParameter("__cmd"));
	String getFixcon = chk.chkNullString(request.getParameter("__fixCon"),"");

	String getManID = chk.chkNullString(request.getParameter("__manid"),"");
	String getDescThai = chk.chkNullString(request.getParameter("__tdesc"),"");
	String getDescEng = chk.chkNullString(request.getParameter("__edesc"),"");
	String getStartDate = chk.chkNullString(request.getParameter("__startdate"),"");
	String getToDate = chk.chkNullString(request.getParameter("__todate"),"");
	String getlistJS = chk.chkNullString(request.getParameter("__listGenRecord"));
	String getlistJobID = chk.chkNullString(request.getParameter("__listJobID"));
	%>
<head>
<title>Approve Manpower Budget</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
<link href="../CSS/bootstrap.css" rel="stylesheet"  type="text/css">
<link href="../CSS/bootstrap_csc_backend.css" rel="stylesheet"  type="text/css">
<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
<script type='text/javascript' src="../JS/bootstrap.js"></script>
<link href="../CSS/Bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">

<script type='text/javascript' src='../JS/jquery-1.11.1.min.js'></script>
<script src="../JS/jquery-1.11.2.js" type="text/javascript"></script>
<script src="../JS/jquery-ui-1.11.4.js" type="text/javascript"></script>
<script type='text/javascript' src='../JS/bootstrap.js'></script>

<script src="../JS/SCREEN.js"></script>
<SCRIPT TYPE='text/JavaScript' SRC='../TA/JS/TA_SCREEN.js'></SCRIPT>
<script src="../JS/angular-1.3.15/angular.js"></script>
<script type='text/JavaScript' SRC='../JS/ANGULAR/SCREEN_ANGULAR.js'></script>

<script language='javascript'>setLang('<%=screen.getUProfile().get("lang")%>');</script>

<script src="../JS/VIEWCALENDAR.js"></script>
<script src='../JS/ICONSMENU.js'></script>
<script src='../JS/HOTKEY.js'></script>
<script src="../JS/DATEINPUT.js"></script>
<script src="../JS/CscBase.js"></script>
<script src="../JS/CscCalendar.js"></script>

<!-- Call DWR -->
<script type='text/javascript' src='/hr/dwr/interface/ManpowerBudget.js'></script>
<script type='text/javascript' src='/hr/dwr/engine.js'></script>
<script type='text/javascript' src='/hr/dwr/util.js'></script>

<script>getTitleName();</script>
<style>
td.result {
    border: 1px solid black;
}
td.init{
	height: 0px;
}
.alignright{
	text-align: right;
	padding-right:2mm;
}
.alignrightNo2mm{
	text-align: right;
}
</style>
<script type="text/JavaScript">

var lang = getLang();
//-->
var sw = new swaplang2();
//------- Global value --------
var jsonArray = [];
var jsonArrayJS = [];
var chkJsonArray = [];

function goHelp(helpName,inputName){
	with(document.cscform){
		var helpReturn;
		var fixcon;
		var thisdate = "<%=cs.getYYYYMMDD()%>";
		__fixCon.value = "";
		fixcon = "";
		if(inputName=="__manid" ){
			fixcon = "active = '1'";
			helpReturn="__manid:budid,__tdesc:tdesc,__edesc:edesc,__startdate:start_date,__todate:end_date";
		}
		linkHelp_Return(helpName,helpReturn,fixcon);
	}
}

function linkHelp_Return(help,input, fixCon){
	with(document.cscform){
		var nInput = input;
		var filter = fixCon || __fixCon.value;
		if(input.indexOf(":")>0){
			nInput=input.substring(0,input.indexOf(":"));
		}
		obj = eval("document.cscform."+nInput);
		if((obj=="")||(obj.value=="")){
			var param="PRU084.jsp?__helpName="+help+"&__helpReturn="+input+"&__pageCall="+__screen.value+"&__fixCon="+filter+"&__checkVerify=off&__langOn="+__langOn.value;
		}else{
			var param="PRU084.jsp?__helpName="+help+"&__helpReturn="+input+"&__pageCall="+__screen.value+"&__fixCon="+filter+"&__checkVerify=off"+"&__valueSearch="+obj.value+"&__langOn="+__langOn.value;
		}
        //var param="PRU084.jsp?__helpName="+help+"&__helpReturn="+input+"&__pageCall="+__screen.value+"&__fixCon="+filter+"&__checkVerify=off";
		win = window.open(param,"Help","left=150,top=150,width=800,height=400,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
		if(window.focus){win.focus();}
	}
}

function postReturn(){
	with(document.cscform){
		//alert("Search");
		GoSearch();
	}
}

function GoDuplicate(){
	with(document.cscform){
		//Go to Duplicate Page
		var lang = '<%=screen.getUProfile().get("lang")%>';
		if(__manid.value != ''&&__tdesc.value != ''&&__startdate.value != ''&&__todate.value != ''){
			var param="MANPOWER_DUPLICATE.jsp?manid="+__manid.value+"&tdesc="+__tdesc.value+"&edesc="+__tdesc.value+"&startdate="+__startdate.value+"&todate="+__todate.value;
			win = window.open(param,"Duplicate","left=150,top=150,width=800,height=400,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
			if(window.focus){win.focus();}
		}else{
			if(lang === 'eng'){
				alert("'Manpower Budget ID' must not be null.");
			}else{
				alert("รหัสงบประมาณกำลังคนจะต้องไม่เป็นค่าว่าง");
			}
		}
	}
}

function GoSave(){
	with(document.cscform){
		var listGenByJS = __listGenRecord.value; //get gen record by JS to save
		var toSave = true;

		if(listGenByJS.length != 0){
			toSave = addDataToSave(listGenByJS);
		}

		if(toSave){
			var countJS = jsonArrayJS.length;
			var countJSedit = jsonArray.length;
			if(countJS > 0 || countJSedit > 0){
				for(var i = 0;i<countJS;i++){
					jsonArray.push(jsonArrayJS[i]);
				}
				waitingDialog.show('Processing');
				ManpowerBudget.saveRecordJSON(JSON.stringify(jsonArray),AfterSaveManpowerData);
			}
		}
	}
}

function AfterSaveManpowerData(data){
	waitingDialog.hide();
	alert(data);
	GoSearch();
}

function addDataToSave(listGenByJS){
	with(document.cscform){
		var getAllRow = listGenByJS.split(",");
		for(var i = 0;i<getAllRow.length;i++){
			var row = getAllRow[i];
			var budid = $("[name='__thisBudID']").val();
			var jobid = $("[name='__js_jobid$"+row+"']").val();
			var perHead = $("[name='perHead$"+row+"']").val();
			var tempHead = $("[name='tempHead$"+row+"']").val();
			var expathead = $("[name='expathead$"+row+"']").val();
			var consulthead = $("[name='consulthead$"+row+"']").val();
			var perSalary = $("[name='perSalary$"+row+"']").val();
			var tempSalary = $("[name='tempSalary$"+row+"']").val();
			var expatsel = $("[name='expatsel$"+row+"']").val();
			var consultsel = $("[name='consultsel$"+row+"']").val();

			var chk = true;
			var chk2 = true;
			var lang = '<%=screen.getUProfile().get("lang")%>';

			if((perHead == ""|| perHead == null) || (tempHead == ""|| tempHead == null) || (perSalary == ""|| perSalary == null) || (tempSalary == "" || tempSalary == null) || (expathead == "" || expathead == null)	|| (consulthead == ""||consulthead == null) || (expatsel == "" || expatsel == null) || (consultsel == "" || consultsel == null)){

				chk = false;
				chk2 = false;
				if(lang === 'eng'){
					alert("'Permanent Head' or 'Temporary Head' or 'Permanent Salary' or 'Temporary Salary' must not be null at row "+row+".");
				}else{
					alert("ค่า Permanent Head หรือ Temporary Head หรือ Permanent Salary หรือ Temporary Salary จะต้องไม่เป็นค่าว่างที่แถว "+row+"");
				}
			}

			//chk = checkNewBValue(thisNewBasepay,row);

			for(var i = 0;i<jsonArrayJS.length; i++){
				if (jsonArrayJS[i]["jobid"] === jobid){
					chk = false;
				}
			}

			if(chk){
				jsonArrayJS.push({"jobid":jobid,"budid":budid,"perHead":perHead,"tempHead":tempHead,"expathead":expathead,"consulthead":consulthead,"perSalary":perSalary,"tempSalary":tempSalary,"expatsel":expatsel,"consultsel":consultsel});
				console.log("JSJsonArray ==> "+JSON.stringify(jsonArrayJS));
			}else if(!chk2){
				return false;
			}
		}
		return true;
	}
}

function GoDelete(){ //Send to process
	with(document.cscform){
		//Check checkbox from gen by js and gen by search
		var listGenByJS = __listGenRecord.value;
		if(listGenByJS.length != 0){
			delRow(listGenByJS);
		}

		var countcheckboxsearch = 0;
		$('input[name^="__checkbox$"]:checked').each(function(){
			countcheckboxsearch++;
		});

		if(countcheckboxsearch > 0){
		getCheckValue();
		console.log("chkJsonArray ==> "+JSON.stringify(chkJsonArray));
		waitingDialog.show('Processing');
		ManpowerBudget.deleteRecord(JSON.stringify(chkJsonArray),AfterDelManpowerData);
		}
	}
}

function AfterDelManpowerData(data){
	waitingDialog.hide();
	alert(data);
	GoSearch();
}

function getCheckValue(){ //For Delete in Database
	chkJsonArray = [];
	$('input[name^="__checkbox$"]:checked').each(function(){
		var getfieldname = $(this).attr('name');
		var temprow = getfieldname.split("$");
		var row = temprow[1];
		//Set all data of this row
		var budid = $("[name='__thisBudID']").val();
		var jobid = $("[name='jobid$"+row+"']").val();
		var perHead = $("[name='perHead$"+row+"']").val();
		var tempHead = $("[name='tempHead$"+row+"']").val();
		var expathead = $("[name='expathead$"+row+"']").val();
		var consulthead = $("[name='consulthead$"+row+"']").val();
		var perSalary = $("[name='perSalary$"+row+"']").val();
		var tempSalary = $("[name='tempSalary$"+row+"']").val();
		var expatsel = $("[name='expatsel$"+row+"']").val();
		var consultsel = $("[name='consultsel$"+row+"']").val();
		var chk = true;


		for(var i = 0;i<chkJsonArray.length; i++){
			if (chkJsonArray[i]["jobid"] === jobid){
				chk = false;
			}
		}

		if(chk){
			chkJsonArray.push({"jobid":jobid,"budid":budid,"perHead":perHead,"tempHead":tempHead,"expathead":expathead,"consulthead":consulthead,"perSalary":perSalary,"tempSalary":tempSalary,"expatsel":expatsel,"consultsel":consultsel});
		}
	});
}

function delRow(listGenByJS){
	with(document.cscform){
		if(listGenByJS.length == 1){
			var getfieldcheckbox = "input[name='__js_checkbox$"+listGenByJS+"']:checked"; // ''
			$(getfieldcheckbox).each(function(){
				var inputChk = eval("__js_checkbox$"+listGenByJS);
				deleteRow(inputChk);
			});

		}else{
			var splitListGenByJS = listGenByJS.split(",");
			for(var i = 0;i<splitListGenByJS.length;i++){
				var getfieldcheckbox = "input[name='__js_checkbox$"+splitListGenByJS[i]+"']:checked"; // ''
				$(getfieldcheckbox).each(function(){
					var inputChk = eval("__js_checkbox$"+splitListGenByJS[i]);
					deleteRow(inputChk);
				});
			}
		}
	}
}

function deleteRow(btn) {
	with(document.cscform){
	var cell, row, sect;
	if ((cell = btn.parentNode) && (row = cell.parentNode)&& (sect = row.parentNode) && sect.removeChild) {
		row.parentNode.removeChild(cell.parentNode);
		var line = btn.name.substring(btn.name.lastIndexOf("$")+1, btn.name.length);
		var getListRecord = __listGenRecord.value;
		var split_list = getListRecord.split(",");
		if(split_list.length == 1){
			__listGenRecord.value = "";
		}else{
			for (i = 0; i<split_list.length; i++) {
				var thisline = split_list[i];
				if (thisline == line){
					if(i == 0){
						__listGenRecord.value = __listGenRecord.value.replace(line+",","");
					}else{
						__listGenRecord.value = __listGenRecord.value.replace(","+line,"");
					}
				}
			}
		}
	}
	setJobIDFromChild();
	}
}

function setJobIDFromChild(){
	with(document.cscform){
	var listGenByJS = __listGenRecord.value;
	if(listGenByJS.length == 0){
		__getJobIDJS.value = "";
	}
	else if(listGenByJS.length == 1){
		var jobid = $("[name='__js_jobid$"+listGenByJS+"']").val();
		__getJobIDJS.value = "'"+jobid+"'";
	}else{
		__getJobIDJS.value = "";
		var split_list = listGenByJS.split(",");
		for(var i = 0;i<split_list.length;i++){
			var field = "[name='__js_jobid$"+split_list[i]+"']";
			var jobid = $(field).val();
			if(i == 0){
				__getJobIDJS.value = "'"+jobid+"'";
			}else{
				__getJobIDJS.value += ",'"+jobid+"'";
			}
		}
	}
	}
}

function GoApprove(){
	with(document.cscform){
		//Change Status = 1;
		var getmanid = __thisBudID.value;
		if(getmanid != ''){
			if(lang == 'eng'){
				bCon=confirm("Confirm to process Yearly Salary Increase?");
			}else{
				bCon=confirm("ยืนยันข้อมูลการปรับเงินเดือนประจำปี");
			}
			if (bCon==true)	{
				waitingDialog.show('Processing');
				ManpowerBudget.transferApprove(getmanid,AfterApprove);
			}

		}else{
			if(lang === 'eng'){
				alert("'Manpower Budget ID' must not be null.");
			}else{
				alert("รหัสงบประมาณกำลังคนจะต้องไม่เป็นค่าว่าง");
			}
		}
	}
}

function AfterApprove(data){
	with(document.cscform){
		waitingDialog.hide();
		var lang = '<%=screen.getUProfile().get("lang")%>';
		if(data == 'ok'){
			if(lang === 'eng'){
				alert("'This Manpower Budget ID is approved.");
			}else{
				alert("รหัสงบประมาณกำลังคนได้รับการยืนยันแล้ว");
			}
			GoSearch();
		}
	}
}

function GoSearch(){
	with(document.cscform){
		var lang = '<%=screen.getUProfile().get("lang")%>';
		var getmanid = __manid.value;
		if(getmanid != ''){
			var filterheal="";
			filterheal=checkCondition(filterheal,__manid,"manpower_bud_data.budid");
			if(__valueSearch.value !=''){
				filterheal=checkConditionWithSign(filterheal,__valueSearch,__searchBy.value,__conSearch.value);
			}
			__fixCon.value=filterheal;
			search();
		}else{
			if(lang === 'eng'){
				alert("'Manpower Budget ID' must not be null.");
			}else{
				alert("รหัสงบประมาณกำลังคนจะต้องไม่เป็นค่าว่าง");
			}
		}
	}
}

function checkCondition(filcon,objname,targetname){
    with(document.cscform){
		if(objname.value.length>0){
            filcon=checkFilter(filcon);
            filcon+= targetname+"='"+objname.value+"'";
		}
        return filcon;
    }
}

function checkConditionWithSign(filcon,objname,targetname,sign){
    with(document.cscform){
		if(objname.value.length>0){
            filcon=checkFilter(filcon);
            filcon+= targetname+" "+sign+" '"+objname.value+"'";
		}
        return filcon;
    }
}

function checkCondition2(filcon,objname1,objname2,targetname){ // For EmployeeID (Between)
    with(document.cscform){
		var emp1 = objname1.value;
		var emp2 = objname2.value;
		if(emp1 === "" && emp2===""){
			return filcon;
		}else if(emp1 === ""){
			emp1 = emp2;
		}else if(emp2 === ""){
			emp2 = emp1;
		}

		filcon = checkFilter(filcon);
		filcon += targetname+" between '"+emp1+"' and '"+emp2+"'";
        return filcon;
    }
}

function checkFilter(fil){
    if(fil.length>0)
        fil+=" and ";
    return fil;
}

function checkNumFloat(obj,min,max){
		if (obj.value != "") {
			var thisvalue = obj.value;
			if(thisvalue.indexOf(",")>-1){
				thisvalue = thisvalue.replace(",","");
			}
			obj.value = parseFloat(thisvalue)+""; // แปลงจาก 01234.xx เป็น 1234.xx
			checkInputComma(obj);  // ถ้าพิม xxx ก็ให้เป็น xxx.00
			if (min >= 0 && max > 0) 	{
				callMaxMin(obj,min,max); // ตรวจดูว่าค่าที่กรอกเกินค่าสูงสุด หรือต่ำกว่าค่าต่ำสุดหรือไม่
			}
			insertComma(obj); //123456 ==> 123,456
		}
}

function checkInputComma(obj) {
		var temp = obj.value.split(".");
		if (temp.length == 2)  {
			if (temp[1].length == 0) {
				obj.value = obj.value + "00";
			}
			else if (temp[1].length == 1) {
				obj.value = obj.value + "0";
			}
		}
		else {
			obj.value = obj.value + ".00";
		}
}

$(document).ready(function(){
	var originalinput = "";
	$(".chkinput" ).on("focus",function(){
		originalinput = $(this).val();
	}).on("blur",function(){
		var lang = '<%=screen.getUProfile().get("lang")%>';
		var thisinput = $(this).val();
		if(originalinput !== thisinput){
			var thisfieldname = $(this).attr('name');
			var getpos = thisfieldname.split("$");
			var posRow = getpos[1];
			var fieldBackup = "input[name='backup$"+thisfieldname+"']";
			if(thisfieldname.indexOf("perHead$")>-1||thisfieldname.indexOf("tempHead$")>-1||thisfieldname.indexOf("expathead$")>-1||thisfieldname.indexOf("consulthead$")>-1||thisfieldname.indexOf("perSalary$")>-1||thisfieldname.indexOf("tempSalary$")>-1||thisfieldname.indexOf("expatsel$")>-1||thisfieldname.indexOf("consultsel$")>-1){
				var test = thisinput.match("^[0-9]+(\.[0-9]{1,2})*$");
					if (test==null)
					{
						if(lang === 'eng'){
							alert("Data must not be null.");
						}else{
							alert("ข้อมูลไม่สามารถเป็นค่าว่างได้");
						}
						var backdata = $(fieldBackup).val();
						if (backdata!=""){
							$(this).val(backdata);
						}else{
							$(this).val("");
						}
					}else{
						setObjValue(posRow);
					}
			}else{
				setObjValue(posRow);
			}
		}
	});

	$("#cbselected").on("change", function(){
		$(".cbselect").prop('checked', $(this).prop("checked"));
	});

	$(".cbselect").on("change", function(){
		if(!$(this).prop("checked")) {
			$("#cbselected").prop('checked', $(this).prop("checked"));
		}
	});

	function setObjValue(row){ //Ex field1$1
		//Set all data of this row
    var budid = $("[name='__thisBudID']").val();
		var jobid = $("[name='jobid$"+row+"']").val();
		var perHead = $("[name='perHead$"+row+"']").val();
		var tempHead = $("[name='tempHead$"+row+"']").val();
		var expathead = $("[name='expathead$"+row+"']").val();
		var consulthead = $("[name='consulthead$"+row+"']").val();
		var perSalary = $("[name='perSalary$"+row+"']").val();
		var tempSalary = $("[name='tempSalary$"+row+"']").val();
		var expatsel = $("[name='expatsel$"+row+"']").val();
		var consultsel = $("[name='consultsel$"+row+"']").val();


		setObjArray(budid,jobid,perHead,tempHead,expathead,consulthead,perSalary,tempSalary,expatsel,consultsel);
		console.log("jsonArray ==> "+JSON.stringify( jsonArray ));
	}

	function setObjArray(budid,jobid,perHead,tempHead,expathead,consulthead,perSalary,tempSalary,expatsel,consultsel){
    var chk = true;
		for (var i=0; i<jsonArray.length; i++){
			if (jsonArray[i]["jobid"] === jobid){
				jsonArray[i]["budid"] = budid;
				jsonArray[i]["perHead"] = perHead;
				jsonArray[i]["tempHead"] = tempHead;
				jsonArray[i]["expathead"] = expathead;
				jsonArray[i]["consulthead"] = consulthead;
				jsonArray[i]["perSalary"] = perSalary;
				jsonArray[i]["tempSalary"] = tempSalary;
				jsonArray[i]["expatsel"] = expatsel;
				jsonArray[i]["consultsel"] = consultsel;
				chk = false;
			}
		}

    if(chk){//Add new row to ObjJSON
			jsonArray.push({"jobid":jobid,"budid":budid,"perHead":perHead,"tempHead":tempHead,"expathead":expathead,"consulthead":consulthead,"perSalary":perSalary,"tempSalary":tempSalary,"expatsel":expatsel,"consultsel":consultsel});
    }
	}
});

//Add Child Row
function AddChild(){
	with(document.cscform){
		//Do Something(Go to Add Child Page)
		var getChildJS = __getJobIDJS.value;
		var param = "";
		if(getChildJS == ''){
			param = "MANPOWER_ADDCHILD.jsp?listJobID="+__listJobID.value;
		}
		else{
			param = "MANPOWER_ADDCHILD.jsp?listJobID="+__listJobID.value+","+getChildJS;
		}
		var win = window.open(param,"Add Child","left=150,top=150,width=800,height=400,toolbar=no,status=yes,scrollbars=yes,resizable=yes");
		if(window.focus){win.focus();}
	}
}

function addRow(){
	with(document.cscform){
		var last_record = $("input[name=__lastRecord]").val();
		var line = parseInt(last_record)+1;
		__lastRecord.value = line;
		var childRow = __getData_FromChild.value;
		var childData = childRow.split("$");
		//console.log(childData);
		var table = document.getElementById("tableManData").tBodies[0];
		var tr = document.createElement("tr");

		//Begin Check_box
		var cell1 = document.createElement("td");
		cell1.align = "center";
		cell1.className = "result";
		var inputChkBox = document.createElement("input");
		inputChkBox.name = "__js_checkbox$"+line;
		inputChkBox.type = "checkbox";
		var spanChkBox = document.createElement("span");
		spanChkBox.innerHTML = line;
		cell1.appendChild(inputChkBox);
		cell1.appendChild((document.createTextNode(" ")));
		cell1.appendChild(spanChkBox);
		//End Check_box Field

		//Begin Job Field
		var cell2 = document.createElement("td");
		cell2.align = "left";
		cell2.className = "result";

		var jobid = document.createElement("input");
		var thisfield = "__js_jobid$"+line;
		jobid.name = thisfield;
		jobid.style = "text-align:left;";
		jobid.type = "text";
		jobid.size = 8;
		jobid.maxLength = 10;
		jobid.value = childData[0];
		jobid.disabled = "true";

		var JobName = document.createElement("input");
		var thisfield2 = "__js_jobdesc$"+line;
		JobName.name = thisfield2;
		JobName.style = "text-align:left;";
		JobName.type = "text";
		JobName.disabled = "true";
		JobName.size = 20;
		JobName.value = childData[1];
		JobName.maxLength = 20;

		cell2.appendChild(jobid);
		cell2.appendChild((document.createTextNode('\u00A0')));
		cell2.appendChild(JobName);
		//End Job Field

		//Begin BU2 Field
		var cell3 = document.createElement("td");
		cell3.className = "result";
		cell3.align = "left";

		var bu2id = document.createElement("input");
		var thisfield = "__js_bu2id$"+line;
		bu2id.name = thisfield;
		bu2id.style = "text-align:left;";
		bu2id.type = "text";
		bu2id.size = 8;
		bu2id.maxLength = 10;
		bu2id.value = childData[2];
		bu2id.disabled = "true";

		var BU2Name = document.createElement("input");
		var thisfield2 = "__js_bu2desc$"+line;
		BU2Name.name = thisfield2;
		BU2Name.style = "text-align:left;";
		BU2Name.type = "text";
		BU2Name.disabled = "true";
		BU2Name.size = 20;
		BU2Name.value = childData[3];
		BU2Name.maxLength = 20;

		cell3.appendChild(bu2id);
		cell3.appendChild((document.createTextNode(" ")));
		cell3.appendChild(BU2Name);
		//End BU2 Field
		//debugger;
		//Begin Permanent Head Field
		var cell4 = document.createElement("td");
		cell4.className = "result";
		cell4.align = "center";
		var perHead = document.createElement("input");
		var thisfield3 = "perHead$"+line;
		perHead.name = thisfield3;
		perHead.className = "numeric chkinput alignrightNo2mm";
		perHead.type = "text";
		perHead.size = 8;
		perHead.maxLength = 20;
		perHead.value = childData[4];
		perHead.onkeyup = function(){sysIsEdit()};
		perHead.onfocus = function(){callDelComma(this)};
		perHead.onkeypress = function(){chkInteger(event)};
		perHead.onblur = function(){checkNumInt(this,0,900000000)};
		perHead.alt = "Permanent Head Total";
		cell4.appendChild(perHead);
		//End Permanent Head Field

		//Begin Temporary Head Field
		var cell5 = document.createElement("td");
		cell5.className = "result";
		cell5.align = "center";
		var tempHead = document.createElement("input");
		var thisfield4 = "tempHead$"+line;
		tempHead.name = thisfield4;
		tempHead.className = "numeric chkinput alignrightNo2mm";
		tempHead.type = "text";
		tempHead.size = 8;
		tempHead.maxLength = 20;
		tempHead.value = childData[5];
		tempHead.onkeyup = function(){sysIsEdit()};
		tempHead.onfocus = function(){callDelComma(this)};
		tempHead.onkeypress = function(){chkInteger(event)};
		tempHead.onblur = function(){checkNumInt(this,0,900000000)};
		tempHead.alt = "Temporary Head Total";
		cell5.appendChild(tempHead);
		//End Temporary Head Field

		//Begin Expat Head Field
		var cell6 = document.createElement("td");
		cell6.className = "result";
		cell6.align = "center";
		var expathead = document.createElement("input");
		var thisfieldexpat1 = "expathead$"+line;
		expathead.name = thisfieldexpat1;
		expathead.className = "numeric chkinput alignrightNo2mm";
		expathead.type = "text";
		expathead.size = 8;
		expathead.maxLength = 20;
		expathead.value = childData[6];
		expathead.onkeyup = function(){sysIsEdit()};
		expathead.onfocus = function(){callDelComma(this)};
		expathead.onkeypress = function(){chkInteger(event)};
		expathead.onblur = function(){checkNumInt(this,0,900000000)};
		expathead.alt = "Expat Head Total";
		cell6.appendChild(expathead);
		//End Expat Head Field

		//Begin Consult Head Field
		var cell7 = document.createElement("td");
		cell7.className = "result";
		cell7.align = "center";
		var consulthead = document.createElement("input");
		var thisfieldconsult1 = "consulthead$"+line;
		consulthead.name = thisfieldconsult1;
		consulthead.className = "numeric chkinput alignrightNo2mm";
		consulthead.type = "text";
		consulthead.size = 8;
		consulthead.maxLength = 20;
		consulthead.value = childData[7];
		consulthead.onkeyup = function(){sysIsEdit()};
		consulthead.onfocus = function(){callDelComma(this)};
		consulthead.onkeypress = function(){chkInteger(event)};
		consulthead.onblur = function(){checkNumInt(this,0,900000000)};
		consulthead.alt = "Consult Head Total";
		cell7.appendChild(consulthead);
		//End Consult Head Field

		//Begin Permanent Salary Field
		var cell8 = document.createElement("td");
		cell8.className = "result";
		cell8.align = "center";
		var perSal = document.createElement("input");
		var thisfieldperSal = "perSalary$"+line;
		perSal.name = thisfieldperSal;
		perSal.className = "chkinput alignright";
		perSal.type = "text";
		perSal.size = 8;
		perSal.maxLength = 20;
		perSal.style = "text-align:right;padding-right:2mm;";
		perSal.value = childData[8];
		perSal.onkeyup = function(){sysIsEdit();checkComma(this,2)};
		perSal.onkeypress = function(){checkWordNumber(this.value,event)};
		perSal.onblur = function(){checkNumFloat(this,0,10000000)};
		perSal.alt = "Permanent Salary Total";
		cell8.appendChild(perSal);
		//End Permanent Salary Field

		//Begin Temporary Salary Field
		var cell9 = document.createElement("td");
		cell9.className = "result";
		cell9.align = "center";
		var tempSal = document.createElement("input");
		var thisfieldtempSal = "tempSalary$"+line;
		tempSal.name = thisfieldtempSal;
		tempSal.className = "chkinput alignright";
		tempSal.type = "text";
		tempSal.size = 8;
		tempSal.maxLength = 20;
		tempSal.style = "text-align:right;padding-right:2mm;";
		tempSal.value = childData[9];
		tempSal.onkeyup = function(){sysIsEdit();checkComma(this,2)};
		tempSal.onkeypress = function(){checkWordNumber(this.value,event)};
		tempSal.onblur = function(){checkNumFloat(this,0,10000000)};
		tempSal.alt = "Temporary Salary Total";
		cell9.appendChild(tempSal);
		//End Temporary Salary Field

		//Begin Expat Salary Field
		var cell10 = document.createElement("td");
		cell10.className = "result";
		cell10.align = "center";
		var expatsel = document.createElement("input");
		var thisfieldexpat2 = "expatsel$"+line;
		expatsel.name = thisfieldexpat2;
		expatsel.className = "chkinput alignright";
		expatsel.type = "text";
		expatsel.size = 8;
		expatsel.maxLength = 20;
		expatsel.style = "text-align:right;padding-right:2mm;";
		expatsel.value = childData[10];
		expatsel.onkeyup = function(){sysIsEdit();checkComma(this,2)};
		expatsel.onkeypress = function(){checkWordNumber(this.value,event)};
		expatsel.onblur = function(){checkNumFloat(this,0,10000000)};
		expatsel.alt = "Expat Salary Total";
		cell10.appendChild(expatsel);
		//End Expat Salary Field

		//Begin Consult Salary Field
		var cell11 = document.createElement("td");
		cell11.className = "result";
		cell11.align = "center";
		var consultsel = document.createElement("input");
		var thisfieldconsult2 = "consultsel$"+line;
		consultsel.name = thisfieldconsult2;
		consultsel.className = "chkinput alignright";
		consultsel.type = "text";
		consultsel.size = 8;
		consultsel.maxLength = 20;
		consultsel.style = "text-align:right;padding-right:2mm;";
		consultsel.value = childData[11];
		consultsel.onkeyup = function(){sysIsEdit();checkComma(this,2)};
		consultsel.onkeypress = function(){checkWordNumber(this.value,event)};
		consultsel.onblur = function(){checkNumFloat(this,0,10000000)};
		consultsel.alt = "Consult Salary Total";
		cell11.appendChild(consultsel);
		//End Consult Salary Field



		tr.appendChild(cell1);
		tr.appendChild(cell2);
		tr.appendChild(cell3);
		tr.appendChild(cell4);
		tr.appendChild(cell5);
		tr.appendChild(cell6);
		tr.appendChild(cell7);
		tr.appendChild(cell8);
		tr.appendChild(cell9);
		tr.appendChild(cell10);
		tr.appendChild(cell11);
		table.appendChild(tr);

		var getListRecord =  $("input[name=__listGenRecord]").val();
		if(getListRecord == "" ||getListRecord == null){
			__listGenRecord.value = line;
		}else{
			__listGenRecord.value += ","+line;
		}
		setJobIDFromChild();
	}
}

function checkAll(){
	with(document.cscform){
		for(i=0;i<elements.length;i++){
			if(elements[i].type=="checkbox") {
				elements[i].checked=true;
			}
		}
	}
}

function decheckAll(){
	with(document.cscform){
		for(i=0;i<elements.length;i++){
			if(elements[i].type=="checkbox") {
				elements[i].checked=false;
			}
		}
	}
}

</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="cscform" method="post" action ="MANPOWER_APP.jsp">


<!----------BEGIN CSC INITIAL ZONE ------------------------>

<%=screen.InitialVariable()%>

<input type="hidden" name="__cmd" value="<%=request.getParameter("__cmd")%>">
<input type="hidden" name="__screen" value="MANPOWER_APP">
<input type="hidden" name="__help" value="">
<input type="hidden" name="__calendar" value="">
<script language="javascript">getInputFormatDate();</script>
<input type="hidden" name="__companyid" value="<%=screen.getUProfile().get("companyid")%>">
<input type="hidden" name="__referPage" value="">
<input type="hidden" name="__orderBy" value="">
<input type="hidden" name="__fixCon" value="<%=getFixcon%>">
<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
<input type="hidden" name="__langOn" value="false">
<!-- For process class -->
<input type="hidden" name="__getJobIDJS" value="">
<input type="hidden" name="__getData_FromChild" value="">


<!----------END CSC INITIAL ZONE -------------------------->

<div align="center">

    <table height="" align="center" cellpadding="0" cellspacing="0"  border="1" class="largest">
		<tr bgcolor="#3366CC">
		  <td  height="20" class="header" colspan="4">MANPOWER_APP,<span swlang code="SW012662">Approve Manpower Budget</span>&nbsp;</td>
		</tr>
		<tr>
		  <td class="blankspace" colspan="4"></td>
		</tr>
		<tr>
		  <td align="right"><strong><swaplang code='SW011723'>Manpower Budget ID</swaplang>&nbsp;</strong></td>
		  <td colspan="3"><input type="text" name="__manid" size="15" value="<%=getManID%>">
			  	<a href="javascript:goHelp('MMANPOWER_BUDHELP','__manid')" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','../IMAGES/BUTTON/SWAP/SEARCH_SWAP20.gif',1)"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" alt="Help" name="Image2"  border="0" align="absmiddle"></a>&nbsp;&nbsp;
					<button type="button" class="btn btn-primary width100" swlang code="SW013176" onClick="GoDuplicate();">GENDATA</button></a></td>
		</tr>
		<tr>
		  <td align="right"><swaplang code='SW013104'>Manpower Name(Thai)</swaplang>&nbsp;</td>
		  <td colspan="3"><input type="Text" name="__tdesc" size="50" maxlength="100" value="<%=getDescThai%>" onkeypress="chkSpecialStr(event);" onkeyup="sysIsEdit();" onblur="trimValue(this);" onfocus="this.select();" alt="Description(Thai)" onmousemver="toolTip('Description(Thai)')" onmouseout="toolTip()" readonly></td>
		</tr>
		<tr>
		  <td align="right"><swaplang code='SW013105'>Manpower Name(Eng)</swaplang>&nbsp;</td>
		  <td colspan="3"><input type="Text" name="__edesc" size="50" maxlength="100" value="<%=getDescEng%>" onkeypress="chkSpecialStr(event);" onkeyup="sysIsEdit();" onblur="trimValue(this);" onfocus="this.select();" alt="Description(Eng)" onmousemver="toolTip('Description(Eng)')" onmouseout="toolTip()" readonly></td>
		</tr>
		<tr>
		  <td align="right"><swaplang code='SW000306'>Start Date</swaplang>&nbsp;</td>
		  <td colspan="3">
				<input type="text" name="__startdate" size="10" maxlength="10" value="<%=getStartDate%>" onkeypress="chkInteger(event);" onkeyup="sysIsEdit();formatDate(this);" onblur="chkInputDate2(this,__todate)" onfocus="this.select();" alt="Start Date" onmousemver="toolTip('Start Date')" onmouseout="toolTip()" readonly>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<swaplang code='SW000276'>End Date</swaplang>&nbsp;
				<input type="text" name="__todate" size="10" maxlength="10" value="<%=getToDate%>" onkeypress="chkInteger(event);" onkeyup="sysIsEdit();formatDate(this);" onblur="chkInputDate2(__startdate,this)" onfocus="this.select();" alt="To Date" onmousemver="toolTip('To Date')" onmouseout="toolTip()" readonly>
		  </td>
		</tr>
		<tr>
			<td align="right">
			<span swlang code="SW000004">Order By</span>&nbsp;</td>
			<td colspan="3">
				<%=screen.getTagOrder()%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<span swlang code="SW000005">Search By</span>&nbsp;<%=screen.getTagSearchBy()%>
			</td>
		</tr>
		<tr>
			<td align="right"><span swlang code="SW000006">Condition</span>&nbsp;</td>
			<td colspan="3">
				<%=screen.getTagConSearch()%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<span swlang code="SW000007">Key Value</span>&nbsp;<%=screen.getTagValueSearch()%>
			</td>
		</tr>
		<tr>
		  <td class="blankspace" colspan="4"></td>
		</tr>
		<%if(cmd != null && cmd.equals("search")){
			DataSet dsCheckData = new DataSet("select * from mmanpower_bud where budid='"+getManID+"'", screen.getUProfile().get("dbname"), "manpower_bud");
			dsCheckData.initConnection(screen.getUProfile());
			String statusManID = "";
			while(dsCheckData.next()){
				statusManID = dsCheckData.getString("status");
		%>
		<tr>
		  <td colspan="4"><div align="center">
				<button type="button" class="btn btn-primary width100" swlang code="SW003537" onClick="GoSearch();">BACK</button>


			</a>&nbsp;&nbsp;
		  <%if(statusManID.equals("0")){%>
				<button type="button" class="btn btn-primary width100" swlang code="SW005155" onClick="GoApprove();">TRANSFER</button></a>
		  <%}%>
			</div></td>
		</tr>
			<%}%>
		<tr>
		  <td class="blankspace" colspan="4"></td>
		</tr>

		<tr>
		  <!-- Table Here -->
		 <td colspan="4">
			 <table border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#808080" class="large" id="tableManData">
				<tr align="center">
					<%if(statusManID.equals("0")){%><td class="result row3" rowspan="2" width="5%"><b><input type="checkbox" id="cbselected"></b></td><%}%>
					<td class="result row3" rowspan="2" width="25%"><b><span swlang code="SW000780">Job Title</span></b></td>
					<td class="result row3" rowspan="2" width="25%"><b><%=screen.getLabel("mjobcode","bu2")%></b></td>
					<td class="result row3" colspan="4"><b><%=language.equals("eng")?"Budget Head":"จำนวนพนักงาน"%></b></td>
					<td class="result row3" colspan="4"><b><%=language.equals("eng")?"Budget Sum Salary":"เงินเดือน"%></b></td>
				</tr>
				<tr>
					<td class="result row3" align="center"><b><%=language.equals("eng")?"Permanent":"พนักงานประจำ"%></b></td>
					<td class="result row3" align="center"><b><%=language.equals("eng")?"Temporary":"พนักงานชั่วคราว"%></b></td>
					<td class="result row3" align="center"><b><%=language.equals("eng")?"Expat":"ต่างชาติ"%></b></td>
					<td class="result row3" align="center"><b><%=language.equals("eng")?"ConSult":"ที่ปรึกษา"%></b></td>
					<td class="result row3" align="center"><b><%=language.equals("eng")?"Permanent":"พนักงานประจำ"%></b></td>
					<td class="result row3" align="center"><b><%=language.equals("eng")?"Temporary":"พนักงานชั่วคราว"%></b></td>
					<td class="result row3" align="center"><b><%=language.equals("eng")?"Expat":"ต่างชาติ"%></b></td>
					<td class="result row3" align="center"><b><%=language.equals("eng")?"ConSult":"ที่ปรึกษา"%></b></td>
				</tr>

				<%
					String getOrderBy = request.getParameter("__listOrder");
					String sql = "";
					int countRow = 0;

					/*
					DbInquiry inqGetData = new InitialInquiry(screen.getUProfile()).getDbInquiry("Manpower_Bud_Data");
					inqGetData.setColumn("*");
					inqGetData.setFilter(getFixcon);


					DbInquiry inqGetData2 = new InitialInquiry(screen.getUProfile()).getDbInquiry("mjobcode");
					inqGetData2.setColumn("tdesc,edesc,bu1,bu2,bu3,bu4,bu5");
					inqGetData.putChild(inqGetData2);
					if(getOrderBy.indexOf("mjobcode")>-1){
						inqGetData2.setOrderBy(getOrderBy);
					}else{
						inqGetData.setOrderBy(getOrderBy);
					}
					inqGetData.refresh();



					*/
 					/*
					if(screen.getUProfile().getDbType().equalsIgnoreCase("MSSQL")){
						sql = "select manpower_bud_data.budid,manpower_bud_data.jobid,dbo.base64decoder(manpower_bud_data.temp_head) as temp_head,dbo.base64decoder(manpower_bud_data.temp_sal) as temp_sal,dbo.base64decoder(manpower_bud_data.per_head) as per_head,dbo.base64decoder(manpower_bud_data.per_sal) as per_sal,dbo.base64decoder(manpower_bud_data.expat_head) as expat_head,dbo.base64decoder(manpower_bud_data.expat_sal) as expat_sal,dbo.base64decoder(manpower_bud_data.consult_head) as consult_head,dbo.base64decoder(manpower_bud_data.consult_sal) as consult_sal from manpower_bud_data INNER JOIN mjobcode on manpower_bud_data.jobid = mjobcode.jobcodeid where "+getFixcon+" ORDER BY "+getOrderBy+";";
					}else{
						sql = "select manpower_bud_data.budid,manpower_bud_data.jobid,base64decoder(manpower_bud_data.temp_head) as temp_head,base64decoder(manpower_bud_data.temp_sal) as temp_sal,base64decoder(manpower_bud_data.per_head) as per_head,base64decoder(manpower_bud_data.per_sal) as per_sal,base64decoder(manpower_bud_data.expat_head) as expat_head,base64decoder(manpower_bud_data.expat_sal) as expat_sal,base64decoder(manpower_bud_data.consult_head) as consult_head,base64decoder(manpower_bud_data.consult_sal) as consult_sal from manpower_bud_data INNER JOIN mjobcode on manpower_bud_data.jobid = mjobcode.jobcodeid where "+getFixcon+" ORDER BY "+getOrderBy+";";
					}


					DataSet inqGetData = new DataSet(sql, screen.getUProfile().get("dbname"), "manpower_bud_data");
					inqGetData.initConnection(screen.getUProfile()); */

					DbInquiry inqGetData = new InitialInquiry(screen.getUProfile()).getDbInquiry("manpower_bud_data");
					inqGetData.setColumn("*");
					inqGetData.setFilter(getFixcon);
					inqGetData.setOrderBy(getOrderBy);
					inqGetData.refresh();
					while(inqGetData.next()){
						countRow++;
					%>
					<tr>
						<%if(statusManID.equals("0")){%>
						<td align="center" class="result">
							<input type="checkbox" class="cbselect" name="__checkbox$<%=countRow%>">
						</td>
						<%}%><%//=countRow%>
					<%

					DbInquiry inqGetJobDesc = new InitialInquiry(screen.getUProfile()).getDbInquiry("Mjobcode");
					inqGetJobDesc.setColumn("tdesc,edesc,bu2");
					inqGetJobDesc.setFilter("jobcodeid ='"+inqGetData.getString("jobid")+"'");
					inqGetJobDesc.refresh();
					String getJobID = inqGetData.getString("jobid");
					String getJobDesc = "";
					String getBU2 = "";
					while(inqGetJobDesc.next()){
						if(language.equals("eng")){
							getJobDesc = inqGetJobDesc.getString("edesc");
							getBU2 = inqGetJobDesc.getString("BU2");
						}else{
							getJobDesc = inqGetJobDesc.getString("tdesc");
							getBU2 = inqGetJobDesc.getString("BU2");
						}
					}%>

						<td align="left" class="result">
							<input type="text" name="jobid$<%=countRow%>" value="<%=getJobID%>" size="8" align="left" class="chkinput" style="text-align:left;" disabled>
							<input type="text" name="jobdesc$<%=countRow%>" value="<%=getJobDesc%>" size="20" align="left" class="chkinput" style="text-align:left;" disabled>
						</td>
					<%
					DbInquiry inqGetBU2 = new InitialInquiry(screen.getUProfile()).getDbInquiry("MBU2");
					inqGetBU2.setColumn("tdesc,edesc");
					inqGetBU2.setFilter("bu2id ='"+getBU2+"'");
					inqGetBU2.refresh();
					String getBU2Desc = "";
					while(inqGetBU2.next()){
						if(language.equals("eng")){
							getBU2Desc=inqGetBU2.getString("edesc");
						}else{
							getBU2Desc=inqGetBU2.getString("tdesc");
						}
					}%>
						<td align="left" class="result">
							<input type="text" name="bu2id$<%=countRow%>" value="<%=getBU2%>" size="8" align="left" class="chkinput" style="text-align:left;" disabled>
							<input type="text" name="bu2desc$<%=countRow%>" value="<%=getBU2Desc%>" size="20" align="left" class="chkinput" style="text-align:left;" disabled>
						</td>
						<%
							String getPerHead = inqGetData.getString("per_head");
							String getTempHead = inqGetData.getString("temp_head");
							String getPerSalary = inqGetData.getString("per_sal");
							String getTempSalary = inqGetData.getString("temp_sal");
							String getExpatHead = inqGetData.getString("expat_head");
							String getExpatSalary = inqGetData.getString("expat_sal");
							String getConsultHead = inqGetData.getString("consult_head");
							String getConsultSalary = inqGetData.getString("consult_sal");

							BigDecimal bctotal1 = new BigDecimal(Double.valueOf(getPerSalary));
							BigDecimal bctotal2 = new BigDecimal(Double.valueOf(getTempSalary));
							BigDecimal bctotal3 = new BigDecimal(Double.valueOf(getExpatSalary));
							BigDecimal bctotal4 = new BigDecimal(Double.valueOf(getConsultSalary));

							DecimalFormat df = new DecimalFormat("###,###,###,###.00");
							DecimalFormat df2 = new DecimalFormat("###,##0");
							getPerSalary = df.format(bctotal1);
							getTempSalary = df.format(bctotal2);
							getExpatSalary = df.format(bctotal3);
							getConsultSalary = df.format(bctotal4);


							getPerHead = df2.format(Double.valueOf(getPerHead));
							getTempHead = df2.format(Double.valueOf(getTempHead));
							getExpatHead = df2.format(Double.valueOf(getExpatHead));
							getConsultHead = df2.format(Double.valueOf(getConsultHead));


							if(getPerSalary.equals(".00")){
								getPerSalary = "0.00";
							}
							if(getTempSalary.equals(".00")){
								getTempSalary = "0.00";
							}
							if(getExpatSalary.equals(".00")){
								getExpatSalary = "0.00";
							}
							if(getConsultSalary.equals(".00")){
								getConsultSalary = "0.00";
							}
						%>
						<td align="center" class="result">
							<input type="text" name="perHead$<%=countRow%>" size="8" maxlength="20" value="<%=getPerHead%>"  class="numeric chkinput" onkeypress="chkInteger(event);" onkeyup="sysIsEdit();" onblur="checkNumInt(this,0,900000000);" onfocus="callDelComma(this);" alt="Permanent Head Total" onmousemver="toolTip('Permanent Head Total')" onmouseout="toolTip()"
							<%=(statusManID.equals("1"))?"disabled":""%>>
							<input type="hidden" name="backup$perHead$<%=countRow%>" value="<%=getPerHead%>"></input>
						</td>
						<td align="center" class="result">
							<input type="text" name="tempHead$<%=countRow%>" size="8" maxlength="20" value="<%=getTempHead%>"  class="numeric chkinput" onkeypress="chkInteger(event);" onkeyup="sysIsEdit();" onblur="checkNumInt(this,0,900000000);" onfocus="callDelComma(this);" alt="Temporary Head Total" onmousemver="toolTip('Temporary Head Total')" onmouseout="toolTip()"
							 <%=(statusManID.equals("1"))?"disabled":""%>>
							 <input type="hidden" name="backup$tempHead$<%=countRow%>" value="<%=getTempHead%>"></input>
						</td>

						<td align="center" class="result"> <!-- expathead -->
							<input type="text" name="expathead$<%=countRow%>" size="8" maxlength="20" value="<%=getExpatHead%>"  class="numeric chkinput" onkeypress="chkInteger(event);" onkeyup="sysIsEdit();" onblur="checkNumInt(this,0,900000000);" onfocus="callDelComma(this);" alt="Expat Head Total" onmousemver="toolTip('Expat Head Total')" onmouseout="toolTip()"
							<%=(statusManID.equals("1"))?"disabled":""%>>
							<input type="hidden" name="backup$expathead$<%=countRow%>" value="<%=getExpatHead%>"></input>
						</td>

						<td align="center" class="result"> <!-- consulthead -->
							<input type="text" name="consulthead$<%=countRow%>" size="8" maxlength="20" value="<%=getConsultHead%>"  class="numeric chkinput" onkeypress="chkInteger(event);" onkeyup="sysIsEdit();" onblur="checkNumInt(this,0,900000000);" onfocus="callDelComma(this);" alt="Consult Head Total" onmousemver="toolTip('Consult Head Total')" onmouseout="toolTip()"
							 <%=(statusManID.equals("1"))?"disabled":""%>>
							 <input type="hidden" name="backup$consulthead$<%=countRow%>" value="<%=getConsultHead%>"></input>
						</td>

						<td align="center" class="result">
							<input type="text" name="perSalary$<%=countRow%>" value="<%=getPerSalary%>" size="8" style="text-align:right;padding-right:2mm;" onkeypress="checkWordNumber(this.value,event);" onkeyup="sysIsEdit();checkComma(this,2);" onblur="checkNumFloat(this,0,10000000)" class="chkinput"
							 <%=(statusManID.equals("1"))?"disabled":""%>>
							 <input type="hidden" name="backup$perSalary$<%=countRow%>" value="<%=getPerSalary%>"></input>
						</td>
						<td align="center" class="result">
							<input type="text" name="tempSalary$<%=countRow%>" value="<%=getTempSalary%>" size="8" style="text-align:right;padding-right:2mm;" onkeypress="checkWordNumber(this.value,event);" onkeyup="sysIsEdit();checkComma(this,2);" onblur="checkNumFloat(this,0,10000000)" class="chkinput"
							 <%=(statusManID.equals("1"))?"disabled":""%>>
							 <input type="hidden" name="backup$tempSalary$<%=countRow%>" value="<%=getTempSalary%>"></input>
						</td>

						<td align="center" class="result"> <!-- Expatsalary -->
							<input type="text" name="expatsel$<%=countRow%>" value="<%=getExpatSalary%>" size="8" style="text-align:right;padding-right:2mm;" onkeypress="checkWordNumber(this.value,event);" onkeyup="sysIsEdit();checkComma(this,2);" onblur="checkNumFloat(this,0,10000000)" class="chkinput"
							 <%=(statusManID.equals("1"))?"disabled":""%>>
							 <input type="hidden" name="backup$expatsel$<%=countRow%>" value="<%=getExpatSalary%>"></input>
						</td>

						<td align="center" class="result">  <!-- Consultsalary -->
							<input type="text" name="consultsel$<%=countRow%>" value="<%=getConsultSalary%>" size="8" style="text-align:right;padding-right:2mm;" onkeypress="checkWordNumber(this.value,event);" onkeyup="sysIsEdit();checkComma(this,2);" onblur="checkNumFloat(this,0,10000000)" class="chkinput"
							 <%=(statusManID.equals("1"))?"disabled":""%>>
							 <input type="hidden" name="backup$consultsel$<%=countRow%>" value="<%=getConsultSalary%>"></input>
						</td>
					</tr>
					<%
						if(countRow == 1){
							getlistJobID = "'"+getJobID+"'";
						}else{
							getlistJobID += ",'"+getJobID+"'";
						}
					}
					inqGetData.closeConnection();%>
			<input type="hidden" name="__lastRecord" value="<%=countRow%>">
			<input type="hidden" name="__thisBudID" value="<%=getManID%>">
			<input type="hidden" name="__listGenRecord" value="<%=getlistJS%>"><!-- List of row gen by JS -->
			<input type="hidden" name="__listJobID" value="<%=getlistJobID%>"><!-- List of row gen by JS -->
			</table>
		</td>
		</tr>
		<tr>
			<td colspan="4"  class="blankspace"></td>
		</tr>
		<%if(statusManID.equals("0")){%>

			<tr>
				<td  class="buttonline" colspan="7"><div align="center">
					<button type="button" class="btn btn-primary width100" swlang code="SW013165" onClick="AddChild();">ADD</button>&nbsp;
					<button type="button" class="btn btn-primary width100" swlang code="SW013166" onClick="GoDelete();">DELETE</button>&nbsp;
					<button type="button" class="btn btn-primary width100" swlang code="SW013175" onClick="GoSave();">SAVE</button>
				</div>
				</td>
			</tr>
		<tr>
			<td colspan="4" class="blankspace"></td>
		</tr>
		<%}%>
		<%}else{%>

			<tr>
				<td  class="buttonline" colspan="7"><div align="center">
					<button type="button" class="btn btn-primary width100" swlang code="SW003537" onClick="GoSearch();">Search</button>
				</div>
				</td>
			</tr>
		<%}%>
		<tr>
		  <td class="blankspace" colspan="4"></td>
		</tr>
		<tr>
			<td class="bottom"  colspan="4"> </td>
		</tr>
  </table>
  </div>

</form>
</body>
<script>
	//Credit by Nheung(Chamnan)
	var waitingDialog = waitingDialog || (function ($) {
		'use strict';

		// Creating modal dialog's DOM
		var $dialog = $(
			'<div class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-hidden="true" style="padding-top:15%; overflow-y:visible;">' +
			'<div class="modal-dialog modal-m">' +
			'<div class="modal-content">' +
				'<div class="modal-header"><h3 style="margin:0;"></h3></div>' +
				'<div class="modal-body">' +
					'<div class="progress progress-striped active" style="margin-bottom:0;"><div class="progress-bar" style="width: 100%"></div></div>' +
				'</div>' +
			'</div></div></div>');

		return {
			show: function (message, options) {
				// Assigning defaults
				if (typeof options === 'undefined') {
					options = {};
				}
				if (typeof message === 'undefined') {
					message = 'Loading';
				}
				var settings = $.extend({
					dialogSize: 'm',
					progressType: '',
					onHide: null // This callback runs after the dialog was hidden
				}, options);

				// Configuring dialog
				$dialog.find('.modal-dialog').attr('class', 'modal-dialog').addClass('modal-' + settings.dialogSize);
				$dialog.find('.progress-bar').attr('class', 'progress-bar');
				if (settings.progressType) {
					$dialog.find('.progress-bar').addClass('progress-bar-' + settings.progressType);
				}
				$dialog.find('h3').text(message);
				// Adding callbacks
				if (typeof settings.onHide === 'function') {
					$dialog.off('hidden.bs.modal').on('hidden.bs.modal', function (e) {
						settings.onHide.call($dialog);
					});
				}
				$dialog.modal();
			},
			hide: function () {
				$dialog.modal('hide');
			}
		};

	})(jQuery);
</script>
</html>