<jsp:useBean id="task" scope="page" class="com.csc.library.system.Task"/>
<%@ page import="com.csc.library.entry.*,com.csc.library.utilities.*,com.csc.library.session.*" contentType="text/html; charset=UTF-8"%>
<%
    CheckNull chk = new CheckNull();

    task.setChannel(request ,response);
    UiManager screen;
    screen=(UiManager)task.process("SingleEntry","change_pwd");


    String strUser_id = screen.getUProfile().get("pwemployee");
    String strPassword = screen.getUProfile().get("password");

	screen.getRecord("pwemployee").set("pwemployee",strUser_id);
    screen.getRecord("pwemployee").search();
 
	String ack="";
    if((request.getParameter("__ack")!=null)&&((request.getParameter("__ack").equals("ack")))){
	ack="ack";
    }
%>
<html>
<head>
<title>Budget Management</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../CSS/TEXT_FONT.css" type="text/css">
</head>
<script language="JavaScript" src="../JS/IMAGE.js"></script>
<script language="javascript" src="../JS/SCREEN.js"></script>
<script language="javascript" src="../JS/MISC.js"></script>
<script src="../JS/HOTKEY.js"></script>
<script language="javascript">setLang('<%=screen.getUProfile().get("lang")%>');</script>

<SCRIPT LANGUAGE="JavaScript">
<!--
function showHelp(){
  with(document.cscform){
   window.open("./help/change_pwd.htm","Doc","left=150,top=150,width=700,height=500,toolbar=no,status=no,scrollbars=yes,resizable=yes");
  }
}
function chkPasswd(){
    with(document.cscform){
        if(Trim(__pwpassword.value) != Trim(__confirm.value)){
	    alert("password and confirm password must be the same");
	    return false;
	}
	return true;
    }
}

function initDoc(){
    setDisabled();
	return;
}

function resetForm(){
    setEmpty();
//    setEnabled();
}

function setEmpty(){
    with(document.cscform){
        __pwpassword.value = "";
        __confirm.value = "";
    }
}

function setEnabled(){
    with(document.cscform){
        __pwusername.disabled = false;
    }
}

function setDisabled(){
    with(document.cscform){
        __pwusername.disabled = true;
    }
}

function setFocus(obj){
    obj.focus();
}

function setSelect(obj){
    obj.select();
}

function saveForm(){
	with(document.cscform){
	        if(Trim(__pwpassword.value)==""){
				alert("กรุณากรอกรหัสผ่าน");
			}else if(Trim(__confirm.value)==""){
				alert("กรุณายืนยันรหัสผ่าน");
			}else{
	        bCon=confirm("ต้องการบันทึกข้อมูลหรือไม่ ?");
    if(chkPasswd()){
            if (bCon==true)	{
        		setEnabled();
				document.cscform.__pwpassword.value = Trim(document.cscform.__pwpassword.value);
				__cmd.value="save";
				submit();
//		        save();
		}
    } else {
        setSelect(document.cscform.__confirm);
        setFocus(document.cscform.__confirm);
    }
	}
	}
}

//-->
</script>

<body leftMargin=0 topMargin=0 MarginHeight="0" marginWidth="0" onload="initDoc()">
<br>
<form name="cscform" method="post" action="">


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

<%=screen.InitialVariable()%>

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

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
	  <td valign="top" width="78%">
        <table width="70%" border="0" align="center"cellpadding="0" cellspacing="0">
          <tr>
            <td width="3%"><img SRC="../IMAGES/TABLE_TOP_LEFT.gif" width="31" height="30"></td>
            <td nowrap width="92%" bgcolor="#1D95E2" align="center"><b>เปลี่ยนรหัสผ่าน</b></td>
            <td width="5%"><img SRC="../IMAGES/TABLE_TOP_RIGHT.gif" width="31" height="30"></td>
          </tr>
          <tr bgcolor="#1D95E2">
            <td colspan="3">
              <table width="100%" border="0" bgcolor="#1D95E2">
                <tr>
                  <td bgcolor="#FFFFFF">
                    <table width="80%" border="0" align="center" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0">
                      <tr>
                        <td colspan="2" valign="baseline"><font  size="2"><b>login name</b></font></td>
                        <td colspan="2" width="58%" valign="middle"><%=screen.getInput("pwusername")%>
                        </td>
                      </tr>
                      <tr>
                        <td colspan="2" valign="baseline"><font  size="2"><b>รหัสผ่าน</b></font></td>
                        <td colspan="2" width="58%" valign="middle"><%=screen.getInput("pwpassword")%>
                        </td>
                      </tr>
                      <tr>
                        <td colspan="2" valign="baseline"><font  size="2"><b>ยืนยันรหัสผ่าน</b></font></td>
                        <td colspan="2" width="58%" valign="middle">
                          <input type="password" name="__confirm" size="10" maxlength="10">
                        </td>
                      </tr>
                    </table>
                    <br>
                    <table width="50%" border="0" align="center">
                      <tr>
                        <td>
                          <div align="center">
                            <a href="javascript:saveForm();"><img  alt="บันทึกข้อมูล" border=0 name="ImageSave" SRC="../IMAGES/POOM_SAVE.gif" width="32" height="32"></a><a href="javascript:resetForm();"><img  alt="เคลียร์ฟอร์ม" name="ImageCancel" border=0 SRC="../IMAGES/POOM_CANCEL.gif" width="32" height="32"></a>
                          </div>
                        </td>
                      </tr>
                    </table>
                  </td>
                </tr>
              </table>
            </td>
          </tr>
          <tr>
            <td width="3%"><img SRC="../IMAGES/TABLE_BOTTOM_LEFT.gif" width="31" height="30"></td>
            <td width="92%" bgcolor="#E1E1E1">&nbsp;</td>
            <td width="5%"><img SRC="../IMAGES/TABLE_BOTTOM_RIGHT.gif" width="31" height="30"></td>
          </tr>
        </table>
        <input type="hidden" name="__cmd">
	<input type="hidden" name="__id" value="<%=request.getParameter("__id")%>">
	<input type="hidden" name="__screen" value="change_pwd">
	<input type="hidden" name="__user_id" value="<%=screen.getRecord("pwemployee").getString("pwemployee")%>">
	<input type="hidden" name="__fname" value="<%=screen.getRecord("pwemployee").getString("pwfname")%>">
	<input type="hidden" name="__lname" value="<%=screen.getRecord("pwemployee").getString("pwlname")%>">
	<input type="hidden" name="__pwgroupid" value="<%=screen.getRecord("pwemployee").getString("pwgroup")%>">
	 <input type="hidden" name="__language" value ="<%=screen.getUProfile().get("lang")%>"> 
	<input type="hidden" name="__jspname" value="change_pwd">
	</td>
    </tr>
</table>
</form>
</body>
</html>