<%@page contentType="text/html;charset=UTF-8" pageEncoding="ISO-8859-1" session="true"
%><%@page errorPage="AdminException.jsp"
%><%@page import="com.fujitsu.iflow.model.workflow.WFAdminSession"
%><%@page import="com.fujitsu.iflow.model.wfcore.WFAdminSessionImpl"
%><%@page import="com.fujitsu.iflow.model.workflow.ProcessInstance"
%><%@page import="com.fujitsu.iflow.model.workflow.Plan"
%><%@page import="com.fujitsu.iflow.model.workflow.WFObjectList"
%><%@page import="com.fujitsu.iflow.model.workflow.WFObjectFactory"
%><%@page import="com.fujitsu.iflow.server.dataobjects.ProcessInstanceStatesEnum"
%><%@page import="com.fujitsu.iflow.server.dataobjects.ProcessDefinitionStatesEnum"
%><%@page import="com.fujitsu.iflow.server.dataobjects.FilterEnum"
%><%@page import="com.fujitsu.iflow.model.workflow.Filter"
%><%@page import="java.util.Date"
%><%@page import="java.util.Enumeration"
%><%@page import="java.util.StringTokenizer"
%><%@page import="java.io.Writer"
%><%@page import="com.fujitsu.iflow.model.bpm.BPMAdmin"
%><%@page import="com.fujitsu.iflow.model.bpm.BPMSession"
%><%@page import="com.fujitsu.iflow.model.bpmcore.BPMAdminImpl"
%><%

    request.setCharacterEncoding("UTF-8");request.getParameterNames(); //Need dummy call for WL9.1
    BPMSession bps = (BPMSession) session.getAttribute("BPMSession");
    if (bps == null) {
        %><jsp:include page="PasswordPanel.jsp" flush="true"/><%
        return;
    }

    BPMAdmin bpas = bps.getAdmin();
    WFAdminSessionImpl wfSession = ((BPMAdminImpl)bpas)._wfas;

    session.setAttribute("TabIndex","1");
    long startDate = System.currentTimeMillis();
    long endDate = System.currentTimeMillis();

%>


<html>
<head>
<title>Interstage Business Process Manager | Archive Process Instances</title>
<jsp:include page="StyleSheet.jsp" flush="true"/>
<script language="javascript" src="styles/clockscripts.js"></script>
<style type="text/css">@import url(calendar/calendar-win2k-1.css);</style>
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
</head>

<body class="adminBodyClass">
<script>
function archive()
{
	var startDate = document.archiveProcess.startDate.value;
	startDate = new Date(startDate).getTime()


	var endDate = document.archiveProcess.endDate.value;
	endDate = new Date(endDate).getTime()

	if(isNaN(startDate) || isNaN(endDate) || startDate < 0 || endDate < 0)
	{
		alert("Either the Start or End date formate is not correct.");
	}
	else if (endDate >= startDate)
	{
		document.location.href= 'Archive.jsp?startDate=' +  startDate + '&endDate=' + endDate;
	}
	else
	{
		alert("The start date should be earlier than end date.");
	}
}

function dateChanged(hidden, viewed)
{
    if (viewed.value == "")
    {
        hidden.value = "";
    }
    else
    {
        validateDate(hidden, viewed);
	}
}

</script>
<center>

<jsp:include page="AdminHeader.jsp" flush="true"/>
<br><br>
<TABLE border="0" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC" class="tableClass" width="450" align= "center">
    <form name="archiveProcess" method="post" action="Archive.jsp">
    <tr>
        <td class="headrow">Specify Date Range: </td>
    </tr>
    <tr>
            <td bgcolor="#FFFFFF" align="left"><br/> Enter Start Date :
            <input type="hidden" name="hiddenStartDate" value="" size="14"/>
            <input type="text" size =20 name= "startDate" value=<%= startDate %> onChange="dateChanged(archiveProcess.hiddenStartDate,archiveProcess.startDate);"/>
            <input type="image" name="button_StartCal" src="calendar/cal.gif" width="16" height="15"/>
            <script type="text/javascript">
                archiveProcess.startDate.value = formatDate(archiveProcess.startDate.value);
                Calendar.setup({inputField  : "startDate", button      : "button_StartCal"});
                showTimeZone();
            </script>
            </td>


    </tr>
    <tr>
            <td bgcolor="#FFFFFF" align="left"><br/> Enter End Date :
            <input type="hidden" name="hiddenEndDate" value="" size="14"/>
            <input type="text" size =20 name= "endDate" value=<%= endDate %> onChange="dateChanged(archiveProcess.hiddenEndDate,archiveProcess.endDate);"/>
            <input type="image" name="button_EndCal" src="calendar/cal.gif" width="16" height="15"/>
            <script type="text/javascript">
                archiveProcess.endDate.value = formatDate(archiveProcess.endDate.value);
                Calendar.setup({inputField  : "endDate", button      : "button_EndCal"});
                showTimeZone();
            </script>
            </td>
    </tr>

    <tr>
        <td valign="middle" align="center" bgcolor="#EEEEEE">
        <input type="button" onClick="archive()" value="Archive Process Instances" class="core-button">
        </td>
    </tr>
    </form>
</table>




</center>
</body>
</html>

<%!

    public WFAdminSessionImpl getiFlowSession(Object modelObject)
    {
            return (WFAdminSessionImpl)(modelObject);
    }

%>
