<%@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.WorkItem"
%><%@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.WorkItemStatesEnum"
%><%@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.text.SimpleDateFormat"
%><%@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;

	String returnMsg = "";

	String sel = request.getParameter("selected");

	WorkItem wi = null;
	long id = -1;
	long processId = -1;
	long activityId = -1;
	String workitemName = "";
	String assignee = "";
	String workitemState = "";
	String planOwners = "";
	String planName = "";
	String processName = ""; 
	String wiCreationTime ="";

	String workitemId = request.getParameter("workitemId");
	String userId = request.getParameter("userId");    


	if (workitemId == null) {
	workitemId = (String) session.getAttribute("workitemId");
	}

	//DO NOT MERGE THE ABOVE CODE INTO THE IF-LOOP below
	id = Long.parseLong(workitemId);

	try {

	wi = WFObjectFactory.getWorkItem(id, wfSession);

	workitemName = wi.getName();
	processName = wi.getProcessInstanceName();
	processId = wi.getProcessInstanceId();
	activityId = wi.getNodeInstanceId();
	planName = wi.getPlanName();
	workitemState = WorkItemStatesEnum.from_int(wi.getState()).toString();
	wiCreationTime = "" + wi.getCreationTime();
	assignee = wi.getAssignee();

	}
	catch(Exception ex)
	{
	returnMsg = "Could not retrieve workitem with id " + id + "."; 
	}

	String[] bcolor = {"evenrow","oddrow"};
	int nextColor = 0;
	String rowColor = bcolor[nextColor];

	session.setAttribute("TabIndex","3");





%>


<html>
<head>
<title>Interstage Business Process Manager | User Management</title>
<jsp:include page="StyleSheet.jsp" flush="true"/>
<script language="javascript" src="styles/clockscripts.js"></script>
</head>

<body class="bodyClass"  onLoad="goforit()">
<script>

function setAssignees(val, id, processId, userId, newAssignee)
{
    location.href='WorkitemReassign.jsp?workitemId=' + id + "&assignee=" + newAssignee +"&userId=" + userId + "&processId=" + processId + "&selected=1";
}

</script>

<center>

<jsp:include page="AdminHeader.jsp" flush="true"/>

<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr>
<td valign="top">
        <form name="wiSumForm" method="get" action="WorkitemReassign.jsp">
          <input type="hidden" name="workitemId" value="-1">
          <input type="hidden" name="processId" value="-1">
	  <input type="hidden" name="selected" value="-1">
	  <input type="hidden" name="userId" value="-1">	  
<br><br>	
<TABLE  border="0" cellpadding="2" cellspacing="1" class="tableClass" width="90%" align="center" bgcolor="#CCCCCC">	

	    <tr align="center" class="headrow">
            <td colspan="3" bgcolor="#EEEEEE" style="filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#FFFFFF', endColorStr='#6699CC', gradientType='1')"><font color="#000000" size="2">Workitem Summary</font></td>
            </tr>             
            <tr><td colspan="1" class="headrow"> ID </td><td bgcolor="#FFFFFF" colspan="2"><%= id %></td></tr>
            <tr><td colspan="1" class="headrow"> Name </td><td bgcolor="#FFFFFF" colspan="2"><%= workitemName %></td></tr>
	    <tr><td colspan="1" class="headrow"> State </td><td bgcolor="#FFFFFF" colspan="1"><%= workitemState %></td></tr>
	    
	    <tr><td colspan="1" class="headrow"> Assignee </td>
	    <td bgcolor="#FFFFFF" colspan="2"><input type=text value =<%= assignee %> name=assignee size=30>
	    <%
	    if (workitemState.equals("Active"))
	    {
	    %><input type="button" onClick="setAssignees('1',<%= id %>, <%= processId %>, '<%= userId %>', this.form.assignee.value)" value="Modify Assignee" name="check" class="core-button"></td>
	    <%
	    }
	    %>
	    </tr>
	    <tr><td colspan="1" class="headrow"> Creation Time </td><td bgcolor="#FFFFFF" colspan="2">
	    <script> showDate('<%=wiCreationTime%>'); </script>
	    </td></tr>
            <tr><td colspan="1" class="headrow"> Activity ID </td><td bgcolor="#FFFFFF" colspan="2"><%= activityId %></td></tr>
	    <tr><td colspan="1" rowspan= "1" class="headrow"> Process Instance ID </td><td bgcolor="#FFFFFF" colspan="2"><%= processId %></td></tr>
	    <tr><td colspan="1" class="headrow"> Process Instance Name </td><td bgcolor="#FFFFFF" colspan="2"><%= processName %></td></tr>
	    <tr><td width="20%" colspan="1" class="headrow"> Process Definition Name </td><td bgcolor="#FFFFFF" colspan="2"><%= planName %></td></tr>
	    

</TABLE>	    


            </form>
            </td></tr>
        </table>
        
        <!-- Added Larer for changing the layout -->
         
  
</center>
</body>
</html>

<%!
    public WFAdminSessionImpl getiFlowSession(Object modelObject)
    {
    		return (WFAdminSessionImpl)(modelObject);
    }     

   
%>

