<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.utilities.*,com.csc.library.session.*,com.csc.library.database.*,java.util.*"%>
<jsp:useBean id="AS101CH" scope="page" class="com.csc.library.system.Task"/>
<%
	AS101CH.setChannel(request,response);
	UIManager screen = (UIManager)AS101CH.process("ChildEntry","Tapsstate");
%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="../CSS/TISCO.css" rel="stylesheet" type="text/css">
		<link type="text/css" href="../CSS/Bootstrap/css/bootstrap.css" rel="stylesheet" >
		<script type="text/javascript" src="../JS/SCREEN.js"></script>
		<script type="text/javascript" src="../JS/VIEWCALENDAR.js"></script>
		<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
		<script type="text/javascript" src="../JS/angular-1.3.15/angular.js"></script>
		<script type="text/javascript" src="../JS/jquery-2.1.3.min.js"></script>
		<script type='text/javascript' src='../JS/ICONSMENU.js'></script>
		<script type='text/javascript' src='../JS/HOTKEY.js'></script>
		<script type='text/javascript'>setLang('<%=screen.getUProfile().get("lang")%>');</script>
		<script type="text/javascript">
			function goHelp(helpName,inputName){
				var helpReturn = "";
				helpReturn = inputName+":stateid";
				linkHelp_Return(helpName,helpReturn);
			}

			function back(){
				with(window.opener.cscform){
					__cmd.value = 'ack';
	    			submit();	    
				}
			}
		</script>
	</head>
	<body>
		<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
		<script language="javascript">initToolTips();</script>
		<form name="cscform" method="post">

			<!----------BEGIN CSC INITIAL ZONE ------------------------>
			<%=screen.InitialVariable()%>
			<!----------END CSC INITIAL ZONE -------------------------->

			<input type="hidden" name="__cmd" value="">
			<input type="hidden" name="__cmdchild" value=.>
			<input type="hidden" name="__referPage" value="">
			<input type="hidden" name="__fixCon" value="">
			<input type="hidden" name="__help" value="">
			<input type="hidden" name="__notNull" value="<%=screen.getRequire()%>">	
			<input type="hidden" name="__screen" value="Tapsperiod">
			<input type="hidden" name="__gorec" value="<%=request.getParameter("__gorec")%>">
			<input type="hidden" name="__headMulti" value="<%=request.getParameter("__headMulti")%>">
			<input type="hidden" name="__ack" value="<%=request.getParameter("__ack")%>">
			<input type="hidden" name="__notNull" value="<%=screen.getRequire()%>">	
			<input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
			<input type="hidden" name="__Rec_No" value="<%=request.getParameter("__RecNo")%>">
			<input type="hidden" name="__apspeid" value="<%=request.getParameter("__apspeid")%>" >
			<input type="hidden" name="__periodstart" value="<%=request.getParameter("__periodstart")%>">
			<input type="hidden" name="__periodend" value="<%=request.getParameter("__periodend")%>">
			<input type="hidden" name="__calendar">
			<input type="hidden" name="__dateformat" value="DD-MM-YYYY">
			<br/>
			<div align="center">
				<table cellpadding="0"  cellspacing="0">
					<tr>
						<td class="header">AS031,</td>
					</tr>
					<tr>
						<td>
							<div align="center">
								<table class="inframe" cellpadding="0" cellspacing="0">
									<tr>
										<td class="blankspace"></td>
									</tr>
									<tr>
										<td class="columnlabel"><%=screen.getLabel("apsid")%></td>
										<td><%=screen.getInput("apsid")%></td>
									</tr>
									<tr>
										<td class="columnlabel"><%=screen.getLabel("stateid")%></td>
										<td><%=screen.getInput("stateid")%></td>
									</tr>
									<tr>
										<td class="columnlabel"><%=screen.getLabel("tdesc")%></td>
										<td><%=screen.getInput("tdesc")%></td>
									</tr>
									<tr>
										<td class="columnlabel"><%=screen.getLabel("edesc")%></td>
										<td><%=screen.getInput("edesc")%></td>
									</tr>
									<tr>
										<td class="columnlabel"><%=screen.getLabel("apsassessor")%></td>
										<td>
											<%=screen.getInput("apsassessor")%>
										</td>
									</tr>
									<tr>
										<td class="columnlabel"><%=screen.getLabel("datestart")%></td>
										<td><%=screen.getInput("datestart")%></td>
									</tr>
									<tr>
										<td class="columnlabel"><%=screen.getLabel("dateend")%></td>
										<td><%=screen.getInput("dateend")%></td>
									</tr>
									<tr>
										<td class="columnlabel"><%=screen.getLabel("sendmail")%></td>
										<td><%=screen.getInput("sendmail")%></td>
									</tr>
									<tr>
										<td colspan="2">
											<div align="center">
												<span class="buttonline"><a href="javaScript:saveChild();"><img src="../IMAGES/BUTTON/SAVE.gif" width="73" height="23" border="0"></a>&nbsp;&nbsp; <a href="javaScript:backhead();"><img src="../IMAGES/BUTTON/BACK.gif" border="0"></a></span>
											</div>
										</td>
									</tr>
								</table>
							</div>
						</td>
					</tr>
					<tr bordercolor="0069B3">
						<td  class="bottom"></td>
					</tr>
						<% 
						if((request.getParameter("__cmdchild")!=null)&&(!request.getParameter("__cmdchild").equals(""))){%>
						<script language="javascript">back();</script>
						<%}%>
				</table>
			</div>
			<script type="text/javascript">

				$(document).ready(function(){
					$("input[name='__apsid']").val(window.opener.cscform.__apsid.value);

					if ($("input[name='__periodstart']").val() != "" && $("input[name='__stateid']").val() == "0"){
						$("input[name='__datestart']").val($("input[name='__periodstart']").val());
					}

					/*if ($("input[name='__periodend']").val() != "" && $("input[name='__stateid']").val() == "0" ){
						console.log($("input[name='__periodstart']").val());
						$("input[name='__dateend']").val($("input[name='__periodstart']").val());
					}*/

					$("input[name='__datestart']").blur(function(){
						var datestart = new Date( $.convertMyDate( $(this).val() ) );
						var periodstart = new Date( $.convertMyDate( $("input[name='__periodstart']").val() ) );
						var periodend = new Date( $.convertMyDate( $("input[name='__periodend']").val() ) );
						var dateend = new Date( $.convertMyDate( $("input[name='__dateend']").val() ) );
						
						if (datestart < periodstart){
							$(this).val( $("input[name='__periodstart']").val() );
						}

						if (datestart > periodend){
							$(this).val( $("input[name='__periodend']").val() );
							$("input[name='__dateend']").val( $("input[name='__periodend']").val() );
						}
					});

					$("input[name='__dateend']").blur(function(){
						var dateend = new Date( $.convertMyDate( $(this).val() ) );
						var datestart = new Date( $.convertMyDate( $("input[name='__datestart']").val() ) );
						var periodstart = new Date( $.convertMyDate( $("input[name='__periodstart']").val() ) );
						var periodend = new Date( $.convertMyDate( $("input[name='__periodend']").val() ) );

						if (dateend < datestart){
							$(this).val( $("input[name='__datestart']").val() );
						}

						if (dateend > periodend){
							$(this).val( $("input[name='__periodend']").val() );
						}

						if (dateend < periodstart){
							$(this).val( $("input[name='__periodstart']").val() );
						}
					});

					$.convertMyDate=function(datestr){
						var result="";
						result =datestr.substring(6,10)+"-"+datestr.substring(3,5)+"-"+datestr.substring(0,2);
						return result;
					};
				});

			</script>
		</form>
	</body>
</html>