var listMethod = "doList";//리스트 Action
var updateMethod = "doUpdate";//Update Action
var deleteMethod = "doDelete";//Delete Action & Event
var createMethod = "doCreate";//Create Action
var detailFormMethod = "doDetail";//Detail Action
var updateFormMethod = "doUpdateForm";//Update Event
var createFormMethod = "doCreateForm";//Create Action
var updateCancel = "doUpdateCancel";//Update Cancel Event
var deleteCancel = "doDeleteCancel";//Delete Cancel Event
var popupMethod = "doPopup";//Popup Action
window.history.back = null;
window.history.go = null;
window.history.previous = null;
/**
* 등록,삭제,수정을 위한 함수
*/
function submitCommand( targetMethod )
{
if( targetMethod == deleteMethod )
{
if (!confirm("삭제 하시겠습니까?")) {
return false;
}
}
var form1 = document.form1;
form1.targetMethod.value=targetMethod;
ValidateForm();
}
/**
* 조회를 위한 submit
*/
function xSubmit(form) {
// XecureSubmit(form);
form.submit();
}
/**
* 페이징에서 조회를 하기 위한 함수
*/
function goSearch( command,_page ) {
var form1 = document.form1;
with ( form1 ) {
reset();
if( _page != null && _page !="" ) {
page.value=_page;
}
action = command; //"packageName.ClassName.exe";
targetMethod.value=listMethod;
// XecureSubmit(form1);
form1.submit();
}
}
/**
* 달력 년,월,일 셀렉트 박스 만들기 컴포넌트. 이 함수를 호출한 자리에 생성된다.
*
ex : makeDateSelectBox("20060822","yyyy","mm","dd")
* @param now : 오늘 날짜
* @param year : 년도 셀렉트 박스의 name
* @param month : 월 셀렉트 박스의 name
* @param date : 일 셀렉트 박스의 name
*/
function makeDateSelectBox(now,year,month,date)
{
var nYear = now.substring(0,4);
var sYear = parseInt(nYear,10) - 4;
var eYear = parseInt(nYear,10) + 4;
var nMonth = now.substring(4,6);
var nDate = now.substr(6);
document.write(makeSelectBoxString(year,"onChangeLeapDate(form1."+year+",form1."+month+",form1."+date+")","select1",sYear,eYear,nYear));
document.write("년");
document.write(makeSelectBoxString(month,"onChangeLeapDate(form1."+year+",form1."+month+",form1."+date+")","select1",1,12,nMonth));
document.write("월");
document.write(makeSelectBoxString(date,"","select1",1,findLeapEndDate(nYear, nMonth),nDate));
document.write("일");
}
/**
* 해당 년,월에 맞는 일자 셀렉트 박스의 옵션 생성.
*
ex : onChangeLeapDate(form1.year,form1.month,form1.date)
* @param year : 년도 정보를 가지고 있는 객체의 form이름.객체이름
* @param month : 월 정보를 가지고 있는 객체의 form이름.객체이름
* @param date : 일 정보를 가지고 있는 객체의 form이름.객체이름
*/
function onChangeLeapDate(year,month,date) {
var i = 1;
var k = 1;
date.length = findLeapEndDate(year.value, month.value);
var total_days = date.length;
for (i=1 ;i <= total_days;i++) {
k = i;
if(i < 10) k = '0' + k;
date.options[i-1].text=k;
date.options[i-1].value=k;
}
}
/**
* 셀렉트 박스 만들기. 주어진 정보를 가지고 셀렉트 박스 만듬. 주로 날짜에 관련되서 사용되고, 숫자에도 사용 가능함. 숫자 이외는 불가.
*
ex : makeSelectBoxString("YYYY","onChangeLeapDate(form1.year,form1.month,form1.date)","select1",1,12,8)
* @param name : 생성될 셀렉트 박스의 객체이름
* @param onchange : onChange 이벤트에 할당할 이벤트 컨트롤 자바 스크립트 함수
* @param classname : 셀렉트 박스에 적용할 css class명
* @param startNo : 시작 값.
* @param endNo : 종료 값
* @param selectedValue : 디폴트 값
* @return 만들어진 셀렉트 박스 스트링
*/
function makeSelectBoxString(name,onchange,classname,startNo,endNo,selectedValue)
{
if(onchange != "")
{
onchange = 'onChange="'+onchange+'"';
}
if(classname != "")
{
classname = 'class="'+classname+'"';
}
var str = '';
return str;
}
/**
* 해당 년,월에 영향을 받는 해당 년월의 마지막 날짜 찾기
*
ex : findLeapEndDate("2006", "2")
* @param year : 년도 값
* @param month : 월 값
* @return 해당 년월의 마지막 날짜
*/
function findLeapEndDate(year, month) {
year = parseInt(year,10);
month = parseInt(month,10);
var endDay=31;
if(month == 2) {
if(( (year % 4 == 0) && (year % 100 != 0) ) || ( year % 400 == 0 ) ) {
endDay = 29;
}
else {
endDay = 28;
}
}
else if( (month == 4) || (month == 6) || (month == 9) || (month == 11) ) {
endDay = 30;
}
else {
endDay = 31;
}
return endDay;
}
/**
* 보고서 출력
*
ex : goReport("test.rep")
* @param fileName : 파일 명
*/
function goReport(fileName) {
/*
var oldTarget = document.form1.target;
with (form1) {
setSendValue("cmd=report&reportFileName=" + fileName)
target = "Hidden";
formSubmit();
target = oldTarget;
setSendValue("cmd= &reportFileName= ");
}*/
var form1 = document.form1;
var oldTarget = form1.target;
var cmd = document.createElement("input");
cmd.type = "hidden";
cmd.name = "cmd";
cmd.value = "report";
var reportFileName = document.createElement("input");
reportFileName.type = "hidden";
reportFileName.name = "reportFileName";
reportFileName.value = fileName;
with (form1) {
appendChild(cmd);
appendChild(reportFileName);
target = "Hidden";
spiderSubmit();
target = oldTarget;
removeChild(cmd);
removeChild(reportFileName);
submitstat = "false";
}
}
/*
* pdf export
*/
function goPdf()
{
var form1 = document.form1;
var oldTarget = form1.target;
var cmd = document.createElement("input");
cmd.type = "hidden";
cmd.name = "cmd";
cmd.value = "pdf";
with (form1) {
appendChild(cmd);
target = "Hidden";
spiderSubmit();
target = oldTarget;
method = "POST";
removeChild(cmd);
submitstat = "false";
}
}
/**
* 엑셀 출력
*
ex : goReport("test.csv")
* @param fileName : 파일 명
*/
function goExcel(fileName) {
/*
var oldTarget = document.form1.target;
with (form1) {
setSendValue("cmd=excel&excelFileName=" + fileName)
method = "GET";
target = "Hidden";
formSubmit();
target = oldTarget;
method = "POST";
setSendValue("cmd= &excelFileName= ");
}
*/
var form1 = document.form1;
var oldTarget = form1.target;
var cmd = document.createElement("input");
cmd.type = "hidden";
cmd.name = "cmd";
cmd.value = "excel";
/*
var excelFileName = document.createElement("input");
excelFileName.type = "hidden";
excelFileName.name = "excelFileName";
excelFileName.value = fileName;
*/
with (form1) {
appendChild(cmd);
// appendChild(excelFileName);
method = "GET";
target = "Hidden";
spiderSubmit();
target = oldTarget;
method = "POST";
removeChild(cmd);
// removeChild(excelFileName);
submitstat = "false";
}
}
/**
* 외환은행 계좌 번호 마스크 씌우기.
*
ex : onkeyup="javascript:formatKebAct(this)"
* @param elem : mask 할 객체
*/
function formatKebAct(elem){
if ( event.keyCode < 32 ) return elem;
if( (event.shiftKey == false && event.keyCode > 47 && event.keyCode < 58 ) || (event.keyCode > 64 && event.keyCode < 90 ) || (event.keyCode > 96 && event.keyCode < 123 ))
{
} else {
if(event.keyCode == 37 || event.keyCode == 38 || event.keyCode == 39 || event.keyCode == 40 || event.keyCode == 229)
{}else{
elem.value = elem.value.substring(0,elem.value.length-1);
}
}
var acNo=elem.value.replace(/-|\//g,"");
var acNoLength=acNo.length;
if (acNoLength <= 3) {
return;
}
//차세대계좌번호
if(acNo.substr(0, 1) == "6" || acNo.substr(0, 1) == "7" || acNo.substr(0, 1) == "8" || acNo.substr(0, 1) == "9") {
if ((acNoLength >= 4) && (acNoLength < 10)) {
elem.value = acNo.substr(0,3)+"-"+acNo.substring(3);
}
else if ( acNoLength >= 10 ) {
elem.value = acNo.substr(0,3)+"-"+acNo.substr(3,6)+"-"+acNo.substring(9);
} else elem.value = acNo;
//현세대계좌번호
} else {
if (acNoLength == 4) {
elem.value = acNo.substr(0,3)+"-"+acNo.substring(3);
} else if (acNoLength == 5) {
elem.value = acNo.substr(0,3)+"-"+acNo.substring(3)+"-";
} else if (acNoLength >= 6) {
//4,5,6 번째 값이 모두 숫자가 아니면 외화 계좌로 취급
if( (acNo.substr(3,1) <= 9) || (acNo.substr(4,1) <= 9) || (acNo.substr(5,1) <= 9) )
{
if ((acNoLength >= 6) && (acNoLength <= 10)) {
elem.value = acNo.substr(0,3)+"-"+acNo.substr(3,2)+"-"+acNo.substring(5);
}
else if (acNoLength == 11) {
elem.value = acNo.substr(0,3)+"-"+acNo.substr(3,2)+"-"+acNo.substr(5,5)+"-"+acNo.substring(10);
}
else if (acNoLength > 11) {
elem.value = acNo.substr(0,3)+"-"+acNo.substr(3,2)+"-"+acNo.substr(5,7)+"-"+acNo.substring(12);
} else return acNo;
} else //외화계좌
{
if ((acNoLength >= 6) && (acNoLength <= 11)) {
elem.value = acNo.substr(0,3)+"-"+acNo.substr(3,3)+"-"+acNo.substring(6);
}
else if (acNoLength == 12) {
elem.value = acNo.substr(0,3)+"-"+acNo.substr(3,3)+"-"+acNo.substr(6,5)+"-"+acNo.substring(11);
}
else if( acNoLength >= 13) {
elem.value = acNo.substr(0,3)+"-"+acNo.substr(3,3)+"-"+acNo.substr(6,6)+"-"+acNo.substring(12);
} else return acNo;
}
}
}
}
/**
* 기간 조회시 시작일자 ~ 종료일자 타입에서 기간을 정해서 사용할때 사용
*
ex : setSearchDate('form1.시작일자','form1.종료일자',-7) -> form1.시작일자.value=오늘일자+ -7일전 날자, 'form1.종료일자'.value=오늘 일자
* @param before : 세번째 파라미터로 받은 몇일 후 날짜를 셋팅할 객체
* @param after : 오늘 날짜를 셋팅할 객체
* @param day : 몇일간의 기간. 0일 경우 당일 조회로 before,after객체의 날짜는 같다.
*/
function setSearchDate(before,after,day) {
var beforeDate = eval(before);
var afterDate = eval(after);
var nowDate = new Date();
var nextDate = new Date();
nextDate.setDate(nowDate.getDate()+day);
var yyyy = nowDate.getFullYear();
var mm = nowDate.getMonth()+1;
var dd = nowDate.getDate();
if(mm < 10) mm = "0"+mm;
if(dd < 10) dd = "0"+dd;
afterDate.value = yyyy+"-"+mm+"-"+dd;
yyyy = nextDate.getFullYear();
mm = nextDate.getMonth()+1;
dd = nextDate.getDate();
if(mm < 10) mm = "0"+mm;
if(dd < 10) dd = "0"+dd;
beforeDate.value = yyyy+"-"+mm+"-"+dd;
}
//현재 월의 일수 계산
function getNowDate(){
var nowDate = new Date();
var yyyy = nowDate.getFullYear();
var mm = nowDate.getMonth()+1;
return findLeapEndDate(yyyy,mm);
}
function goReload(command, gubun) {
var form1 = document.form1;
form1.action = command+"?gubun="+gubun;
form1.submit();
}
// Number and '-' key input agree
function setKeyDateType(e)
{
if(event.keyCode < 48 || event.keyCode > 57) // this is not number type
{
// enter, tab, backspace...
if(event.keyCode == 8 || event.keyCode == 9
|| event.keyCode == 37 || event.keyCode == 39) // || event.keyCode == 45) // '-'
{
return true;
}
event.returnValue = false;
}
else // this is number type (YYYY-MM-DD)
{
var dateValue = e.srcElement.value;
if(dateValue != "" && dateValue != null)
{
if(dateValue.length == 4)
{
e.srcElement.value = dateValue + "-";
}
else if(dateValue.length == 7)
{
e.srcElement.value = dateValue + "-";
}
else if(dateValue.length == 6)
{
var monthPrefix = dateValue.substring(5, 6);
if(monthPrefix != "0" && monthPrefix != "1")
{
e.srcElement.value = dateValue.substring(0, 5) + "0"
+ dateValue.substring(5, 6) + "-" + dateValue.substring(6);
}
}
}
}
}
function isAllNumeric(SrcStr)
{
var str = "1234567890";
for (ki=0; ki < SrcStr.length; ki++)
{
sstr = SrcStr.charAt(ki);
if(str.indexOf(sstr) == -1) return false;
}
return true;
}
function isAllNumericOrPointOrHipon(SrcStr)
{
var str = "-1234567890.";
for (ki=0; ki < SrcStr.length; ki++)
{
sstr = SrcStr.charAt(ki);
if(str.indexOf(sstr) == -1) return false;
}
return true;
}
function isAllNumericOrPoint(SrcStr)
{
var str = "1234567890.";
for (ki=0; ki < SrcStr.length; ki++)
{
sstr = SrcStr.charAt(ki);
if(str.indexOf(sstr) == -1) return false;
}
return true;
}
function isAllNumericOrHiPon(num)
{
var str = "-1234567890 ";
for (ki=0; ki < num.length; ki++)
{
sstr = num.charAt(ki);
if(str.indexOf(sstr) == -1) return false;
}
return true;
}
function int_check(str)
{
if(str.charAt(0) >= 0 && str.charAt(0) < 9)
{
return false;
}
return true;
}
function eng_check(str)
{
var tmp;
for(i=0; i < str.length; i++)
{
tmp = str.charAt(i);
if(tmp >= "a" && tmp <= "z" || tmp >= "A" && tmp <= "Z" || tmp >= "0" && tmp <= "9" || tmp == "," || tmp == "." || tmp == " ")
{
continue;
}
else
{
return false;
}
}
return true;
}
function eng_check1(str)
{
var tmp;
for(i=0; i < str.length; i++)
{
tmp = str.charAt(i);
if(tmp >= "a" && tmp <= "z" || tmp >= "A" && tmp <= "Z" || tmp >= "0" && tmp <= "9" || tmp == "," || tmp == " " || tmp.indexOf("@")!=-1 || tmp.indexOf(".")!=-1 || tmp.indexOf("_")!=-1 || tmp.indexOf("-")!=-1)
{
continue;
}
else
{
return false;
}
}
return true;
}