MOVEMENT.js 2.4 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
/**
* @author: James
* @create date: 12/3/2553
* @description: Ѻ Movement v.3 
*
*/

function setAdjustType(){
	with(document.cscform) {
		var adjType = 20;
		adjType += changeAgencies() +changePosition() +changeSalary();
		var orgType = __tadjposition$adj_type$1.value;
		if(orgType != '1' && orgType != '3' && orgType != '10' && orgType != '30') {
			__tadjposition$adj_type$1.value = adjType;
		}
	}
}

function changeAgencies() {
	with(document.cscform) {
		if( isChacge(__tadjposition$old_branch$1.value, __tadjposition$branch$1.value) ) {
			return 1;
		}
		if( isChacge(__tadjposition$old_bu1$1.value, __tadjposition$bu1$1.value) ) {
			return 1;
		}
		if( isChacge(__tadjposition$old_bu2$1.value, __tadjposition$bu2$1.value) ) {
			return 1;
		}
		if( isChacge(__tadjposition$old_bu3$1.value, __tadjposition$bu3$1.value) ) {
			return 1;
		}
		if( isChacge(__tadjposition$old_bu4$1.value, __tadjposition$bu4$1.value) ) {
			return 1;
		}
		if( isChacge(__tadjposition$old_bu5$1.value, __tadjposition$bu5$1.value) ) {
			return 1;
		}
		return 0;
	}
}

function changePosition() {
	with(document.cscform) {
		if( isChacge(__tadjposition$old_emp_position$1.value, __tadjposition$emp_position$1.value) ) {
			return 2;
		}
		return 0;
	}
}

function changeSalary() {
	with(document.cscform) {
		if( isChacge(__tadjposition$old_salatype$1.value, __tadjposition$salatype$1.value) ) {
			return 4;
		}
		if( isChacge(__tadjposition$old_currency$1.value, __tadjposition$currency$1.value) ) {
			return 4;
		}
		if( isChacge(__tadjposition$old_emp_every$1.value, __tadjposition$emp_every$1.value) ) {
			return 4;
		}
		var keysList = document.getElementsByName("keys");
		if( keysList && keysList.length>0) {
			try {
				for(var index=0; index<keysList.length; index++) {
					var keyStr = keysList[index].value;
					var oValue = document.getElementsByName("__tadjsalary$old_amount$" +keyStr)[0].value;
					var nValue = document.getElementsByName("__tadjsalary$amount$" +keyStr)[0].value;
					if( isChacge(toDecimal(oValue), toDecimal(nValue) ) ) {
						return 4;
					}
				}
			} catch (err) { }
		} else {
			if( isChacge( __tadjposition$old_salary$1.value, __tadjposition$salary$1.value) ) {
				return 4;
			}
		}
		return 0;
	}
}

function toDecimal(vStr) {
	var tmp = vStr.replace(/,/g, "");
	//return parseFloat(tmp, 10);
	return tmp*1;
}
function isChacge(oValue, nValue) {
	if(oValue != nValue) { 
		return true;
	}
	return false;
}