/* * Author = Dian Hermanto * Create Date = 21 Maret 2014 * File Name = allscript.css * Function = Default page after login * Location = ./asset/js/allscript.js */ function confirmDelete() { return confirm("Are you sure you want to delete this file?"); } function validateInVendCat() { if(document.getElementById('VendCat_Name').value == '') { alert('Vendor Category can not empty.') return false; } } // Purchase Requisition function selPURRREQ_Type(myValue) { var type = document.getElementById('PURRREQ_Type').value; if(type==2) { document.getElementById('labelProject1').style.display = ''; document.getElementById('labelProject2').style.display = ''; } else { document.getElementById('labelProject1').style.display = 'none'; document.getElementById('labelProject2').style.display = 'none'; } } function doCloseChild(myChild) { if(myChild.length) { for(var i=0;i=0;i--) { j = j + 1; if (j == 3) { bil3 = "." + bil3 } else if ((j >= 6) && ((j % 3) == 0)) { bil3 = "," + bil3 } bil3 = bil2.charAt(i) + "" + bil3 } ini.value = bil3 } function decimalin1(ini) { var i, j; var bil2 = deletecommaperiod(ini,'both') var bil3 = "" j = 0 for (i=bil2.length-1;i>=0;i--) { j = j + 1; if (j == 3) { bil3 = "." + bil3 } else if ((j >= 6) && ((j % 3) == 0)) { bil3 = "," + bil3 } bil3 = bil2.charAt(i) + "" + bil3 } return bil3; } function ReturnToNumberFormat(value) { arrNum = value.split(','); var A = arrNum.join(""); return A; } /*********************************************************************************************************************************/ // Syntax : // PopWindow(URL, Title, Width, Height, Attributes); // Example : // PopWindow('http://doweb1/satria/test.cfm','WindowName', '730', '580', 'scrollbars=yes,location=yes,status=yes'); // Attributes Parameter can be filled with following options : // toolbar=no/yes, location=no/yes, directories=no/yes, status=no/yes, menubar=no/yes, scrollbars=no/yes, resizable=no/yes function PopWindow(theUrl, theName, theWidth, theHeight) { // Updated by Bing, Oct 08, 2002 //alert(theUrl); var theAttributes = '' if(arguments[4]!=null) theAttributes = arguments[4] if (theUrl==null || theWidth==null || theHeight==null || theUrl.length==0 || theWidth.length==0 || theHeight.length==0) return false; var theLeft = Math.ceil((screen.width - 10 - theWidth) / 2); var theTop = Math.ceil((screen.height - 30 - theHeight) / 2); var varAttributes = "width="+theWidth+",height="+theHeight+",left="+theLeft+",top="+theTop; if(theAttributes.length==0) varAttributes = varAttributes + ",toolbar=0,location=0,directories=0,status=0,menubar=-0,scrollbars=1,resizable=1"; else varAttributes = varAttributes + "," + theAttributes; return window.open(theUrl, theName, varAttributes); } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ // Usage : // if (trimkarakter(document.formname.formfield.value).length == 0) // { // alert("Fill in the field"); // document.formname.formfield.focus(); // } function trimkarakter(str) { var i, j, k, hasil, tamp; if (str.length == 0) return str; hasil = ""; tamp = ""; i = 0; do { if (str.charAt(i) == " ") { tamp = str.charAt(i); i++; } else tamp = '%'; } while (tamp == " "); j = str.length - 1; do { if (str.charAt(j) == " ") { tamp = str.charAt(j); j--; } else tamp = '%'; } while (tamp == " "); for (k=i;k<=j;k++) hasil = hasil + str.charAt(k); return hasil; } function deletespaces(str) { var A = new Array(); A = str.split("\n"); str = A.join(""); A = str.split(" "); str = A.join(""); A = str.split("\t"); str = A.join(""); return str; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ // Usage : // spec_char = ""; Fill in with 'not allowed' Special Character, blank to use default; // if (!check_spec_char(document.formname.formfield.value,spec_char) // { // alert("Fill in the field"); // document.formname.formfield.focus(); // } /* function check_spec_char(object_value,spec_char) { if (object_value.length == 0) return true; if (spec_char == null) return false; if (spec_char.length == 0) spec_char = '~`/-!$#%^&*()+={}[]|\\:;"\'<,>?'; var check; for (var i = 0; i < object_value.length; i++) { check = spec_char.indexOf(object_value.charAt(i)); if (check > 0) return false; else if (check == 0) return false; } return true; } */ function check_spec_char(object_value,spec_char) { /* if (object_value.length == 0) return true; if (spec_char == null) return false; */ if (spec_char.length == 0) spec_char = '~`/-!$#%^&*()+={}[]|\\:;"\'<,>?'; var check; for (var i = 0; i < object_value.length; i++) { check = spec_char.indexOf(object_value.charAt(i)); if (check >= 0) { return true; } //else if (check == 0) //return false; } return false; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ function selectunselect(object_value) { for (var i=0;i= 1.0) { checkdigit++; } doubledigit = false; } else { checkdigit += tempdigit; doubledigit = true; } } return (checkdigit % 10) == 0 ? true : false; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ // Usage : // int_format = ""; Fill in with 'allowed' Integer Format // if (!check_integer(document.formname.formfield.value,int_format)) // { // alert("Fill in the field"); // document.formname.formfield.focus(); // } // Use this function to accept a valid Integer Format // If number_format is not blank (not ""), the function will use the defined number_format // If number_format is blank (""), the function will use following format : // The number value can be +/- number. // Example : -3, +62, 62. function check_integer(object_value,int_format) { if (object_value.length == 0) return true; if (int_format == null) return false; var decimal_format = "."; var check_char; if (int_format.length != 0) { for(var i=0;i max_value) return false; } return true; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ // This function is deprecated. Use ValidateEmail instead. //function check_email(mail) //{ //mailpatern = new RegExp('^[a-zA-Z]+(([_]|\\.)?[a-zA-Z0-9])*@([a-zA-Z0-9]+([_]?[a-zA-Z0-9])*(\\.))+[a-zA-Z]{2,4}$'); //mailpatern = new RegExp('^[a-zA-Z]+(([_]|\\.)?[a-zA-Z0-9_-])*@([a-zA-Z0-9_-]+([_]?[a-zA-Z0-9-_])*(\\.))+[a-zA-Z]{2,4}$'); //mailpattern = new RegExp('^[^0-9-()<>:?&*!~`=|#$%]+@[^#$%]*(\\.)+[^#$%]{2,4}$'); // mailpattern = new RegExp('^[a-zA-Z]+(([_]|\\.|-)?|[a-zA-Z0-9])*@([a-zA-Z0-9]+([_]?[a-zA-Z0-9])*(\\.))+[a-zA-Z]{2,4}$'); // return mail.search(mailpattern); //} /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ // Usage : // if (!check_email(document.formname.formfield.value)) // { // alert("Fill in the field"); // document.formname.formfield.focus(); // } // Use this function to accept a valid Email Address // This is the other way to describe a valid Email Address // This function is using 'not allowed' characters. function check_email(emailad) { var a = emailad.split(";") var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/; var check=/@[\w\-]+\./; var checkend=/\.[a-zA-Z]{2,3}$/; for(var i=0;i 12) return false; if (inpDate[1] == 00 || inpDate[1] > maxday) return false; if (inpDate[2] == 0000 || inpDate[2].length < 4) return false; //if (inpDate[2] == 0000 || inpDate[2] > Nowyear) return false; return true; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ function check_datebackforward(object_value,varsplit) { /*if (ValidateDate(object_value)) return false; */ if (varsplit == null) return false; if (varsplit.length == 0) varsplit = "/"; var inpDate = new Array(); inpDate = object_value.split(varsplit); var buildmonth = inpDate[0]; var builddate = inpDate[1]; var buildyear = inpDate[2]; if (inpDate.length < 3) return false; if (ValidateNumber(buildmonth)) return false; if (ValidateNumber(builddate)) return false; if (ValidateNumber(buildyear)) return false; var d = new Date(); var Nowyear = d.getYear(); var Nowhour = d.getHours(); var Nowmin = d.getMinutes(); var Nowsec = d.getSeconds(); var maxday = TotDayInMonth(inpDate[0],inpDate[2]); buildmonth = eval(buildmonth) - 1; var TimeNow = new Date(buildyear,buildmonth,builddate,Nowhour,Nowmin,Nowsec); if (TimeNow == d) return false; if (inpDate[0] == 00 || inpDate[0] > 12) return false; if (inpDate[1] == 00 || inpDate[1] > maxday) return false; if (inpDate[2] == 0000 || inpDate[2] > Nowyear) return false; return true; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ function check_date_tomorrowonly(object_value,varsplit) { /*if (ValidateDate(object_value)) return false; */ if (varsplit == null) return false; if (varsplit.length == 0) varsplit = "/"; var inpDate = new Array(); inpDate = object_value.split(varsplit); var buildmonth = inpDate[0]; var builddate = inpDate[1]; var buildyear = inpDate[2]; if (inpDate.length < 3) return false; if (ValidateNumber(buildmonth)) return false; if (ValidateNumber(builddate)) return false; if (ValidateNumber(buildyear)) return false; var d = new Date(); var Nowyear = d.getYear(); var Nowmonth = d.getMonth(); var Nowdate = d.getDate(); Nowdate = eval(Nowdate) - 1; var Nowhour = d.getHours(); var Nowmin = d.getMinutes(); var Nowsec = d.getSeconds(); var maxday = TotDayInMonth(inpDate[0],inpDate[2]); buildmonth = eval(buildmonth) - 1; var TimeNow = new Date(buildyear,buildmonth,builddate,Nowhour,Nowmin,Nowsec); //d = new Date(Nowyear,Nowmonth,Nowdate,Nowhour,Nowmin,Nowsec); /*alert('timenow='+TimeNow+'\n'+'d='+d) if (TimeNow == d) alert('timenow == d') else if (TimeNow < d) alert('timenow < d') else if (TimeNow > d) alert('timenow > d')*/ if (TimeNow < d) return false; if (inpDate[0] == 00 || inpDate[0] > 12) return false; if (inpDate[1] == 00 || inpDate[1] > maxday) return false; //if (inpDate[2] == 0000 || inpDate[2] > Nowyear) return false; if (inpDate[2] === 0000) return false; return true; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ function ChangeDatewDefault(objdate,objmonth,objyear) { var i, j; var seldate = objdate.selectedIndex; var selmonth = objmonth.selectedIndex; var selyear = objyear.selectedIndex; if (selmonth > 0) { intTotDay = TotDayInMonth(selmonth,objyear.options[selyear].value); objdate.options.length = intTotDay; for (i=1;i<=intTotDay;i++) { objdate.options[i-1].value = i; objdate.options[i-1].text = i; } objyear.options.length = 192; j = 1900; for (i=1;i<=192;i++) { objyear.options[i-1].value = j; objyear.options[i-1].text = j; j++; } seldate = ((seldate > intTotDay-1) ? intTotDay-1 : seldate); } else { intTotDay = 1; objdate.options.length = intTotDay; objdate.options[0].value = 0; objdate.options[0].text = 'Day'; objyear.options.length = intTotDay; objyear.options[0].value = 0; objyear.options[0].text = 'Year'; } return true; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ // Sample Usage : // // // // // // This id 1 is used to change the End Time value based on the Start Time value + Duration value. This change is put in Start Time onchange // id 2 : // This id 2 is used to change the End Time value based on the Start Time value + Duration value. This change is put in Duration onchange // id 3 : // This id 3 is used to change the Duration Time value based on the End Time value - Start Time value. This change is put in End Time onchange // id 4 : CHECKED> // This id 4 is used to change the Start Time to 12.00 AM, Duration Time to 23:50, End Time to 11.50 PM together. function ChangeTime(changeid,objstartH,objstartM,objdurH,objdurM,objendH,objendM) { var i; var selStartH = objstartH.selectedIndex; var selStartM = objstartM.selectedIndex; var selDurH = objdurH.selectedIndex; var selDurM = objdurM.selectedIndex; var selEndH = objendH.selectedIndex; var selEndM = objendM.selectedIndex; var intStartH = objstartH.options[selStartH].value*1; var intDurH = objdurH.options[selDurH].value*1; var intEndH = objendH.options[selEndH].value*1; var intStartM = objstartM.options[selStartM].value*1; var intDurM = objdurM.options[selDurM].value*1; var intEndM = objendM.options[selEndM].value*1; if (changeid == 1 || changeid == 2) { //var d, s = "Today's date is: "; //Declare variables. //d = new Date(); //Create Date object. //s += (d.getMonth() + 1) + "/"; //Get month //s += d.getDate() + "/"; //Get day //s += d.getYear(); //Get year. //return(s); //Return date. var dtEndDate = new Date(2000,1,1,intStartH + intDurH, intStartM + intDurM,0); var intEndH = dtEndDate.getHours(); var intEndM = dtEndDate.getMinutes(); for(i=0;i // // // SELECT TCountry.* FROM TCountry Order By Country_Name // SELECT TCountryState.* FROM TCountryState Order By Country_ID,State_ID // SELECT TCountryState.* FROM TCountryState WHERE Country_ID=#selCountry# Order By Country_ID,State_ID // SELECT TCountryCity.* FROM TCountryCity Order By State_ID,City_ID // SELECT TCountryCity.* FROM TCountryCity WHERE State_ID=#selState# Order By State_ID,City_ID // 2. Put the "wddx.js" file in the same file of the caller of this script (File in step 1). // // the wddx.js file // // this file // 3. Put the cfwddx function at the file of the caller of this script. (File in step 1). // // 4. Set the cf settings. (The caller file). // // Country : // // // // // State : // // // // // City : // // // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 5. Important Part : // // max 160 characters /*********************************************************************************************************************************/ function limitChar(obj_,obj_target,nbmax) { if (obj_.value.length > nbmax) { obj_.value=obj_.value.substring(0,nbmax) alert("Sorry, you have reached maximum character allowed"); } obj_target.value=nbmax-obj_.value.length; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ // Usage : /*********************************************************************************************************************************/ function valid_dateformat(object_value) { var varsplit = "/"; var inpDate = new Array(); inpDate = object_value.split(varsplit); for(var i=0;i<2;i++) {//alert(inpDate[i]); if (inpDate[i]) {//alert(inpDate[i]+'1'); if (inpDate[i].length == 1) inpDate[i] = '0'+ inpDate[i] } else {//alert("masuk"); var x = false; break; return x; } } var x = inpDate[0]+'/'+inpDate[1]+'/'+inpDate[2] return x; } /*********************************************************************************************************************************/ /*********************************************************************************************************************************/ // Usage : /*********************************************************************************************************************************/ function change_dateformat(object_value) { var varsplit = "/"; var x = valid_dateformat(object_value); if (!x) { return x; } var inpDate = new Array(); inpDate = x.split(varsplit); x = inpDate[2]+'/'+inpDate[0]+'/'+inpDate[1] return x; } function getyear1(object_value) { var varsplit = "/"; var x = valid_dateformat(object_value); var inpDate = new Array(); inpDate = x.split(varsplit); x = inpDate[2] return x; } function adddate(object_value,i) { var varsplit = "/"; var x = valid_dateformat(object_value); var inpDate = new Array(); inpDate = x.split(varsplit); var y = parseInt(inpDate[1]) + i; x = inpDate[0]+'/'+y+'/'+inpDate[2] return x; } /*Usage : get_max_day_inmonth(month,year), it will return days ammount in the selected month and year*/ function get_max_day_inmonth(month1,year1) { var x = 30; if ((month1 == 1) || (month1 == 3) || (month1 == 5) || (month1 == 7) || (month1 == 8) || (month1 == 10) || (month1 == 12)) { x = 31; return x; } else if (month1 == 2) { if (year1 % 4 == 0) { x = 29; return x; } else { x = 28; return x; } } else { return x; } } /*Usage : get_max_day_inyear(year), it will return days ammount in the selected year*/ function get_max_day_inyear(year1) { var x = 365; if (year1 % 4 == 0) { x = 366; return x; } else { return x; } } /*Usage : subdate(fromdate,todate) , it will return the amount day betwen fromdate to todate please be sure to input the right fromdate and todate, cause there is no validation in this function*/ function subdate(fromdate,todate) { var varsplit = "/"; var hasil = 0; var x = valid_dateformat(fromdate); var y = valid_dateformat(todate); var inpDate1 = new Array(); var inpDate2 = new Array(); inpDate1 = x.split(varsplit); inpDate2 = y.split(varsplit); /*alert('inpDate1: '+inpDate1); alert('inpDate2: '+inpDate2); alert('inpDate1[0]: '+inpDate1[0]); alert('inpDate2[0]: '+inpDate2[0]); alert('inpDate1[1]: '+inpDate1[1]); alert('inpDate2[1]: '+inpDate2[1]); alert('inpDate1[2]: '+inpDate1[2]); alert('inpDate2[2]: '+inpDate2[2]); var coba = parseInt(07); alert('coba: '+coba);*/ var day1 = inpDate1[1]; var month1 = inpDate1[0]; var year1 = inpDate1[2]; var day2 = inpDate2[1]; var month2 = inpDate2[0]; var year2 = inpDate2[2]; var subyear = year2 - year1; var submonth = month2 - month1; var subday = day2 - day1; var i; var dummonth; var dumyear; /*alert('year1: '+year1); alert('year2: '+year2); alert('month1: '+month1); alert('month2: '+month2); alert('day1: '+day1); alert('day2: '+day2); alert('subyear: '+subyear);*/ if (subyear > 0) { dumyear = year1; for(i = 1;i <= subyear;i++) {//alert('masuk subyear'); hasil = hasil + get_max_day_inyear(dumyear); dumyear++; } }//alert(hasil+' 1'); //alert('submonth: '+submonth); if (submonth > 0) { dummonth = month1; dumyear = year1; for(i = 1;i <= submonth;i++) {//alert('masuk submonth'); hasil = hasil + get_max_day_inmonth(dummonth,dumyear); dummonth++; if (dummonth == 13) { dummonth = 1; dumyear++; } } }//alert(hasil+' 2'); if ((subday == 0) && (submonth == 0) && (subyear == 0)) { hasil = 1; } else { hasil = hasil + subday + 1; }//alert(hasil+' 3'); return hasil; } /*********************************************************************************************************************************/ function disablerightclick(nets) { if((!document.all && nets.which!=1) || (document.all && event.button!=1)) alert('This action has been disabled.') return false } function IsChecked(chkBox) { if(chkBox!=null) { var Found = false if(chkBox.length!=null) for(var i=0; (i number to round // N --> decimal digit function RoundNDecimal(X, N) { var T, S=new String(Math.round(X*Number("1e"+N))) while (S.length<=N) S='0'+S return S.substr(0, T=(S.length-N)) + '.' + S.substr(T, N) } function decformat(pval) { var scval=(""+pval).split("."); var stdec="00"; if (scval.length==2) stdec=(""+scval[1]).substr(0,2); var arrnum=new Array; var stnum=""+scval[0]; var stret=""; do { if (stret.length>=3) stret=","+stret; if (stnum.length<=3) { stret=stnum+stret; stnum=""; } else { stret=stnum.substr(stnum.length-3,3)+stret; stnum=stnum.substr(0,stnum.length-3); } } while (stnum.length) return stret+"."+stdec; } /*********************************************************************************************************************************/ // Created by : Indra P., May 8 '09 // usage : doDecimalFormat(100.789798); function doDecimalFormat(angka) { var a, b, c, dec, i, j; angka = String(angka); if(angka.indexOf('.') > -1){ a = angka.split('.')[0] ; dec = angka.split('.')[1] } else { a = angka; dec = -1; } b = a.replace(/[^\d]/g,""); c = ""; var panjang = b.length; j = 0; for (i = panjang; i > 0; i--) { j = j + 1; if (((j % 3) == 1) && (j != 1)) c = b.substr(i-1,1) + "," + c; else c = b.substr(i-1,1) + c; } if(dec == -1) return angka; else return (c + '.' + dec); } /********************************************************************************************************************************* Create by Bing Usage : - Top Checkbox (required) - Details Checkbox (required) *********************************************************************************************************************************/ function checkAll(chkList, chkAll) { if(chkList != null) { if(chkList.length!=null) for(var i=0; i= len) chkAll.checked = true; } } else chkAll.checked = chkList.checked; } } // ****************************************************************** // This function accepts a string variable and verifies if it is a // proper date or not. It validates format matching either // mm-dd-yyyy or mm/dd/yyyy. Then it checks to make sure the month // has the proper number of days, based on which month it is. // The function returns true if a valid date, false if not. // ****************************************************************** function isDate(dateStr,wrongdateformatmsg,wrongmonth,wrongday,month1,noday,nohave,days) { var datePat = /^(\d{1,2})(\/)(\d{1,2})(\/)(\d{4})$/; var matchArray = dateStr.match(datePat); // is the format ok? if ((wrongdateformatmsg.length == 0) || wrongdateformatmsg == "") { wrongdateformatmsg = " Please enter date as mm/dd/yyyy. "; } if ((wrongmonth.length == 0) || wrongmonth == "") { wrongmonth = " Month must between 1 - 12. "; } if ((wrongday.length == 0) || wrongday == "") { wrongday = " day must between 1 - 31. "; } if ((month1.length == 0) || month1 == "") { month1 = " Month "; } if ((noday.length == 0) || noday == "") { noday = " Doesn't have 31 days. "; } if ((nohave.length == 0) || nohave == "") { nohave = " Doesn't have "; } if ((days.length == 0) || days == "") { days = " Days. "; } if (matchArray == null) { alert(wrongdateformatmsg); return false; } month = matchArray[1]; // parse date into variables day = matchArray[3]; year = matchArray[5]; if (month < 1 || month > 12) { // check month range alert(wrongmonth); return false; } if (day < 1 || day > 31) { alert(wrongday); return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert(month1 +month+ noday) return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day > 29 || (day==29 && !isleap)) { alert("February " + year + nohave + day + days); return false; } } return true; // date is valid } // Emulates printf("blah blah %s blah %s",str1,str2) like in C // Used for concatenating message for easier localization. // Returns assembled string. function printf() { var i,numArgs,errStr="",argNum=0,startPos; numArgs = printf.arguments.length; if (numArgs) { theStr = printf.arguments[argNum++]; startPos = 0; endPos = theStr.indexOf("%s",startPos); if (endPos == -1) endPos = theStr.length; while (startPos < theStr.length) { errStr += theStr.substring(startPos,endPos); if (argNum < numArgs) errStr += printf.arguments[argNum++]; startPos = endPos+2; endPos = theStr.indexOf("%s",startPos); if (endPos == -1) endPos = theStr.length; } if (!errStr) errStr = printf.arguments[0]; } return errStr; } function strTrim(AStr) { return AStr.replace(/^\s+/,'').replace(/\s+$/,''); } function isIntOnly(e,elm) { var evt=window.event?event:e; var ekey=evt.keyCode?evt.keyCode:evt.which; var ret=((ekey >= 48 && ekey <= 57) || (ekey >= 35 && ekey <= 39) || ekey == 46 || ekey==13 || ekey==9 || ekey==8);//|| ekey==190 if (ret && elm!=null) { ret=(ekey != 46 || elm.value.search(/\./)==-1); } // window.status+="_"+ret; // if (!ret) alert(ekey); return ret; // return ((event.keyCode == 46) || (event.keyCode >= 48) && (event.keyCode <= 57)) } /********************************************************************************************************************************/ function isIntOnlyNew(evt){ if (evt.which){ var charCode = evt.which; } else if(document.all && event.keyCode){ var charCode = event.keyCode; } else { return true; } return ((charCode == 45) || (charCode == 46) || (charCode == 8) || (charCode >= 48) && (charCode <= 57)); } function isIntOnlyNew1(evt){ var charCode = (evt.which) ? evt.which : event.keyCode; return ((charCode == 8) || (charCode >= 48) && (charCode <= 57)); } /* function decimalin(ini,nottyped){ // ini: object , nottyped: determine whether this function is used for typing (don't set anything) or number format (set 1) var allowedchars="-1234567890.",isminus,end,val,tmpchar,ischar,k,decval,newval; if(event == null || (event.keyCode != 37 && event.keyCode != 39)){ var oldpos=getSelectionStart(ini); val=ini.value; if((event != null) && (!((event.keyCode == 46) || (event.keyCode == 190) || (event.keyCode == 189) || (event.keyCode >= 48) && (event.keyCode <= 57)))){ tmpchar=val.charAt(oldpos-1); ischar=allowedchars.indexOf(tmpchar); if(ischar<0){ var flag=true; var cnt=0; while(flag){ found=val.indexOf(tmpchar); if(found>=0){ val=val.replace(tmpchar,""); } else break; cnt++; if(cnt>15)break; } } } if(oldpos==val.length){ end=1; } else{ end=0; } isminus=0; if(val.charAt(0)=="-"){ val=val.substr(1,val.length) isminus=1; } val=val.split(",").join(""); decval=val.split("."); val=decval[0]; if(val=="")val=0; newval=""; var idx=0 for(k=val.length-1;k>=0;k--){ idx++; newval=val.charAt(k)+newval; if(idx%3==0 && idx < val.length){ newval=","+newval; } } // app_dec variable is declared in erp\eaccounting\application.cfc if(decval[1]!=null){ if(decval[1].length > parseInt(app_dec)){ decval[1]=decval[1].substr(0,parseInt(app_dec)); } newval=newval+"."+decval[1]; } if(isminus==1)newval="-"+newval; ini.value=newval; if(end==1){ oldpos=ini.value.length; } if(nottyped!=1){ setCaretPosition(ini,oldpos); } } } */ /********************************************************************************************************************************* Create by Tiono Usage : Clear select box options *********************************************************************************************************************************/ function ClearSelectObject(selObj) { /* if (selObj.length>0) { for(i=selObj.length-1;i>=0;i--) selObj.options[i] = null; } */ try {while(selObj.hasChildNodes) selObj.removeChild(selObj.lastChild);} catch (e) {} } /********************************************************************************************************************************* Usage : Populate Select Box option. Works for IE, NN+ and firefox. Hope works for other browser also. Example : AddSelectOption(document.frm.selObj, "Label", "value") *********************************************************************************************************************************/ function AddSelectOption(oSelect, label, value, idx) { var oOption = document.createElement('option'); var oLabel = document.createTextNode(label); oOption.appendChild(oLabel); oOption.setAttribute('value', value); try { if (idx==0) oSelect.insertBefore(oOption, oSelect.firstChild); else oSelect.appendChild(oOption); } catch (e) { oSelect.appendChild(oOption); } } /********************************************************************************************************************************* Create by Tiono Usage : Populate combobox with grouping based on parent combobox selected value data array must have following format arr[x][0] = parent combobox id arr[x][1] = data id arr[x][2] = label filterAllId is used to set fill ALL id at parent combobox. If parent doesn't have ALL option then leave this param as empty string '' *********************************************************************************************************************************/ function populateComboBox(dtsource, filterid, targetOSelect, selectedValue, filterAllId) { ClearSelectObject(targetOSelect); for(i=0;i]+ while( script = search.match(/(]*>\s*()?\s*<\/script>)/i))) break; block = search.substr(0, search.indexOf(RegExp.$1)); search = search.substring(block.length + RegExp.$1.length); var oScript = document.createElement('script'); if (block.substr(0,14).toUpperCase()=="CF_RUNCONTENT(") { adembed+=block.substr(15,block.length-18); block=""; } if (block!="") { oScript.text = block; document.getElementsByTagName("head").item(0).appendChild(oScript); } } if (adembed!="") obj.insertAdjacentHTML("beforeEnd",adembed); } function GetXmlHttpObject() { var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } } return xmlHttp; } function getAJAXContent(theURL,plcHolder,keepcursor) { //alert(theURL); // add ............. if (keepcursor==null) keepcursor=0; nmr = 1; var BB = new Array(); BB = theURL.split('&'); for (i=0;i"+xmlHttp.responseText+"")*/ if (keepcursor!=1) document.body.style.cursor="default"; if (divPlc.innerHTML!="" && keepcursor!=3) { divPlc.style.display=""; } } else { return xmlHttp.responseText; } } } xmlHttp.open(ajaxMethod,theURL,true); xmlHttp.send(ajaxParam); if (divPlc!=null && keepcursor==0) { divPlc.style.display="none"; } if (keepcursor!=1) document.body.style.cursor="wait"; } /********************************************************************************************************************************* Create by Tiono Usage : Check if at lease one checkbox is checked *********************************************************************************************************************************/ function isCheckboxChecked(chkobj) { if (chkobj && chkobj.length) {for (i=0;i 2) { alert("Invalid Time Format"); objTime.value = str1+":"+str2 ; } else if(str.split(":")[0] == "" || parseInt(str.split(":")[0],10) < 0 ) { alert("Invalid Time Format"); str1 = "00" ; objTime.value = str1+":"+str2 ; } else if(str.split(":")[1] == "" || parseInt(str.split(":")[1],10) < 0 ) { alert("Invalid Time Format"); str2 = "00" ; objTime.value = str1+":"+str2 ; } else if(parseInt(str.split(":")[0],10)>23 || parseInt(str.split(":")[1],10)>59) { alert("Invalid Time Format"); if(parseInt(str.split(":")[0],10)>23) { str1 = "23" ; } if(parseInt(str.split(":")[1],10)>59) { str2 = "59" ; } objTime.value = str1+":"+str2 ; } else { str1 = parseInt(str.split(":")[0],10); if(parseInt(str.split(":")[0],10)<10) str1 = "0"+parseInt(str.split(":")[0],10); str2 = parseInt(str.split(":")[1],10); if(parseInt(str.split(":")[1],10)<10) str2 = "0"+parseInt(str.split(":")[1],10); objTime.value = str1+":"+str2 ; } } function ceklen(val) { var len = 1 ; var pembagi while((val/pembagi)>1) { len++; pembagi = pembagi * 10 ; } return len ; } function decimalinForMoney(ini){ if(ini.value == '') ini.value = 0; var min = 0; if(parseInt(ini.value) < 0) min = 1 ; else min = 0 ; ini.value = ini.value.split("-").join(""); if(ini != null){ if (ini.value.indexOf('.') >= 0) { // bukan bilangan bulat var pembagi = 1; for(var i=0;i -1) { a = ini.value.split('.')[0] ; dec = ini.value.split('.')[1] } else { a = ini.value; dec = -1; } b = a.replace(/[^\d]/g,""); c = ""; panjang = b.length; j = 0; for (i = panjang; i > 0; i--) { j = j + 1; if (((j % 3) == 1) && (j != 1)) c = b.substr(i-1,1) + "," + c; else c = b.substr(i-1,1) + c; } if(dec == -1) ini.value = c; else ini.value = c + '.' + dec; if(min==1) { ini.value = "-" + ini.value ; } } function decimalinAngka(ini){ if(ini.value == '') ini.value = 0; var min = 0; if(parseInt(ini.value) < 0) min = 1 ; else min = 0 ; ini.value = ini.value.split("-").join(""); if(ini != null){ if (ini.value.indexOf('.') >= 0) { // bukan bilangan bulat var pembagi = 1; for(var i=0;i= 0) { // bukan bilangan bulat var pembagi = 1; for(var i=0;i -1) { a = ini.value.split('.')[0] ; dec = ini.value.split('.')[1] } else { a = ini.value; dec = -1; } b = a.replace(/[^\d]/g,""); c = ""; panjang = b.length; j = 0; for (i = panjang; i > 0; i--) { j = j + 1; if (((j % 3) == 1) && (j != 1)) c = b.substr(i-1,1) + "," + c; else c = b.substr(i-1,1) + c; } if(dec == -1) ini.value = c; else ini.value = c + '.' + dec; if(min==1) { ini.value = "-" + ini.value ; } } function viewdimension(dimensionID,path,obj) { var URL = path+"/include/ajax/inventory/dimensiondetail.cfm?dimension_ID="+dimensionID ; // Start Ajax var pageToRequest = false; if (window.XMLHttpRequest) // if Mozilla, Safari etc pageToRequest = new XMLHttpRequest(); else if (window.ActiveXObject){ // if IE try { pageToRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ pageToRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } else { return false; } pageToRequest.onreadystatechange = function() { if (pageToRequest.readyState == 4) { return overlib(pageToRequest.responseText); } } pageToRequest.open('GET', URL, true); pageToRequest.send(null); } function dimensionDetail(objItem,elementItem,dimension_id,vst_idx){ objItem.setHTTPMethod('POST'); // default is GET objItem.setReturnFormat('json'); // default is JSOn // itemclass.setAsyncMode(); *** Automatic set by below {setCallbackHandler() | setErrorHandler()} objItem.setCallbackHandler(handleGetDimension); objItem.setErrorHandler(handleError); objItem.detailDimension(dimension_id,elementItem,vst_idx); } function handleGetDimension(result){ resultset = result.split("XX") elementItem = resultset[0]; document.getElementById(elementItem).innerHTML = resultset[1] } function handleError(statusCode, statusMsg) { alert('Status: ' + statusCode + ', ' + statusMsg); } function decimalinMoney(nilai2){ var nilai = "" + nilai2 if(nilai == '') nilai = 0; nilai = nilai.split("-").join(""); if(nilai != null){ if (nilai.indexOf('.') >= 0) { // bukan bilangan bulat var pembagi = 1; for(var i=0;i -1) { a = nilai.split('.')[0] ; dec = nilai.split('.')[1] } else { a = nilai; dec = -1; } b = a.replace(/[^\d]/g,""); c = ""; panjang = b.length; j = 0; for (i = panjang; i > 0; i--) { j = j + 1; if (((j % 3) == 1) && (j != 1)) c = b.substr(i-1,1) + "," + c; else c = b.substr(i-1,1) + c; } if(dec == -1) nilai = c; else nilai = c + '.' + dec; return nilai; }