<%@ page language="java" %>
<%@ page import="vkc.view.TabId" %>
<%@ include file="inc/taglib.inc.jsp" %>
<%@ include file="inc/helper.inc.jsp" %>
<vkc:init/>
<bean:define id="form" name="worklistForm"/>

<html:html locale="true">
<head>
    <title><vkc:message key="wf.workflow"/></title>
    <meta http-equiv="content-type"  content="text/html; charset=iso-8859-1" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="pragma"        content="no-cache" />
    <meta http-equiv="expires"       content="0" />
    
	<vkc:cssinclude />

	<link rel="stylesheet" href="<vkc:rewrite page='/templates/${template.name}/workflow/vkc-wf.css'/>" />
	
	<script type="text/javascript" src="<vkc:rewrite page='/common/utils.js'/>"></script>
	<script type="text/javascript">
	window.name = "MAINVIEW";
	var associatedTabId = <%=TabId.WORKFLOW_TAB%>;
    
    function init() {
        var tabView = getTabView();
        var tabViewForm = tabView.document.forms[0];

        if (tabView && tabView.systemviewtype == "categoryview" && tabView.selectedTabId != associatedTabId) {
        	tabView.location.replace("<%=ctxPath%>/vkcTabView.do?selectedTabId=<%=TabId.WORKFLOW_TAB%>"
          						   + "&lastCategoryId=" + tabViewForm.lastCategoryId.value
          						   + "&lastFunctionalId=" + tabViewForm.lastFunctionalId.value
          						   + "&lastProjectId=" + tabViewForm.lastProjectId.value);
        }
    }

    <logic:present parameter="detailId">
    
	function showExplorer(varId, selCatId) {
        var w = 200;
        var h = 600;
        var leftPosition = screen.width/2  - w/2;
        var topPosition  = screen.height/2 - h/2;
        var settings ='height=' + h + ', width=' + w + ', top=' + topPosition + ', left=' + leftPosition;
        settings += ',scrollbars=yes,resizable';
        settings += ',toolbar=no, location=no, directories=no, status=true, menubar=no';
        windowOpen = window.open( '<%=ctxPath%>/explorerTreeView.do?varId='+varId+'&selNode='+selCatId+'&activeNode='+selCatId, 'EXPLORER_MAINVIEW', settings );
        windowOpen.focus();
        return false;                              
    }
    
    function setCategoryId( id, varId ) {
	    var form = document.ID<%=request.getParameter("detailId")%>;
	    document.getElementsByName( "dynaValue("+varId+")")[0].value = id;
        form.action.value = "updateVariables";
        windowOpen = null;
	    form.submit();
    }
    </logic:present>
	</script>
</head>
<body onload="init();">
<table cellspacing="1" cellpadding="2" width="100%" border="0">
 <tr><td align="right"><vkc:img page="/../templates/${template.name}/gfx/wf-workflow.png" border="0" alt=""/></td>
 <td align="left"><h2><vkc:message key="wf.worklist"/></h2></td></tr>
 <vkc:hline colspan="2" lineClass="hline" lineHeight="1" topSpace="5" bottomSpace="5"/>
  <tr>
    <td width="200" align="left" valign="top" nowrap="nowrap">
	<jsp:include page="inc/navigation.inc.jsp">
		<jsp:param name="wf-action" value="worklist"/>
	</jsp:include>
	</td>
		<td width="100%" align="center" valign="center">
<!-- Arbeitsliste -->
		<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">
				<tr>
					<td>
					<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">
					<tr><td align="left" colspan="6"><b>Angenommene Aufgaben</b></td></tr>
			      	<tr><td colspan="6"><hr size="1" noshade="noshade" width="100%" /></td></tr>
<!-- Fehlermeldungen -->
		      		<jsp:include page="inc/error.inc.jsp">
		      			<jsp:param name="colspan" value="6"/>
		      		</jsp:include>
<!-- Messages -->
			      	<jsp:include page="inc/messages.inc.jsp">
		      			<jsp:param name="colspan" value="6"/>
		      		</jsp:include>
					<tr>
						<td class="tableheader"><vkc:message key="wf.workflow"/></td>
						<td class="tableheader">Aufgabe</td>
						<td class="tableheader">Prio</td>
						<td class="tableheader">Erhalten am</td>
						<td class="tableheader">Dauer</td>
						<td class="tableheader">Aktionen</td>
					</tr>
<!-- Angenommene Aufgaben -->
				<logic:iterate id="w" name="workitems.accepted" indexId="index" type="vkc.workflow.model.WorkItemInfo">
					<bean:define id="container" name="w" property="container" type="vkc.workflow.model.ProcessInstanceInfo"/>
					<form name="ID<%=w.getId()%>" action="<%=ctxPath%>/workflow/worklist.do">
						<input type="hidden" name="action" value="complete" />
						<input type="hidden" name="activityId" value="<%=w.getId()%>" />
					<%if(index.intValue() % 2 == 0 ) out.print( "<tr>" ); else out.print( "<tr class=\"tablerow\">" );%>
						<td nowrap valign="top">
							<logic:notEqual parameter="detailId" value="<%=w.getId()%>">
							<vkc:link page="/worklist.do" paramId="detailId" paramName="w" paramProperty="id">
								<vkc:img page='/../templates/${template.name}/gfx/plus.gif' border="0" alt="Details"/>
							</vkc:link>
							</logic:notEqual>
							<logic:equal parameter="detailId" value="<%=w.getId()%>">
							<vkc:link page="/worklist.do">
								<vkc:img page='/../templates/${template.name}/gfx/minus.gif' border="0" alt="Collaps"/>
							</vkc:link>
							</logic:equal>
							 	<vkc:img page='/../templates/${template.name}/gfx/wf-icon.gif' border="0" altKey="wf.visualize_process"/>&#160;
								<vkc:write name="container" property="name"/>
						</td>
						<td nowrap><b><vkc:write name="w" property="name"/></b></td>
						<td nowrap><vkc:write name="w" property="priority"/></td>
						<td nowrap><vkc:write name="w" property="receivedAt" formatKey="date.medium.format"/></td>
						<td nowrap><vkc:write name="w" property="duration"/></td>
						<td nowrap>
						<vkc:link href='<%="javascript:openWindow(640,480,'" + ctxPath + "/workflow/visualizeProcess.do?procId=" + container.getId() + "','" + vkc.util.VKCStringUtils.replaceToken(container.getName(), " ", "_") + "');"%>'>
							 	<vkc:img page='/../templates/${template.name}/gfx/wf-view.png' border="0" altKey="wf.visualize_process"/></vkc:link>&#160;
						<vkc:image page='/../templates/${template.name}/gfx/wf-complete.png' border="0" altKey="wf.complete"/>
						</td>
					</tr>
					
					<logic:equal parameter="detailId" value="<%=w.getId()%>">
					<input type="hidden" name="updateVariables" value="true" />
					<%if(index.intValue() % 2 == 0 ) out.print( "<tr>" ); else out.print( "<tr class=\"tablerow\">" );%>
						<td colspan="6">
						<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">
							<logic:notEmpty name="w" property="description">
							<tr><td valign="top"><b>Beschreibung:</b></td><td colspan="2"><vkc:write name="w" property="description"/></td><tr>
							</logic:notEmpty>
							<logic:notEmpty name="activity.context">
							<tr class="tableheader"><td>Name</td><logic:equal name="form" property="showDataTypes" value="true"><td>Typ</td></logic:equal><td>Wert</td></tr>
							</logic:notEmpty>
							<logic:iterate id="var" name="activity.context" type="vkc.workflow.model.VariableInfo">
							<%@ include file="inc/variables.inc.jsp" %>
							</logic:iterate>
						</table>
						</td>
					</tr>	
					</logic:equal>
					</form>
				</logic:iterate>
					<tr><td align="left" colspan="6">&#160;</td></tr>
					<tr><td align="left" colspan="6"><b>Ausstehende Aufgaben</b></td></tr>
			      	<tr><td colspan="6"><hr size="1" noshade="noshade" width="100%" /></td></tr>
			      	<tr>
						<td class="tableheader"><vkc:message key="wf.workflow"/></td>
						<td class="tableheader">Aufgabe</td>
						<td class="tableheader">Prio</td>
						<td class="tableheader">Ausstehend seit</td>
						<td class="tableheader">Deadline</td>
						<td class="tableheader">Aktionen</td>
					</tr>
<!-- Ausstehende Aufgaben -->				
				<logic:iterate id="w" name="workitems.open" indexId="index" type="vkc.workflow.model.WorkItemInfo">
					<bean:define id="container" name="w" property="container" type="vkc.workflow.model.ProcessInstanceInfo"/>
					<%if(index.intValue() % 2 == 0 ) out.print( "<tr>" ); else out.print( "<tr class=\"tablerow\">" );%>
						<td nowrap valign="top">
							<logic:notEqual parameter="detailId" value="<%=w.getId()%>">
							<vkc:link page="/worklist.do" paramId="detailId" paramName="w" paramProperty="id">
								<vkc:img page='/../templates/${template.name}/gfx/plus.gif' border="0" alt="Details"/>
							</vkc:link>
							</logic:notEqual>
							<logic:equal parameter="detailId" value="<%=w.getId()%>">
							<vkc:link page="/worklist.do">
								<vkc:img page='/../templates/${template.name}/gfx/minus.gif' border="0" alt="Collaps"/>
							</vkc:link>
							</logic:equal>
						 	<vkc:img page='/../templates/${template.name}/gfx/wf-icon.gif' border="0" altKey="wf.visualize_process"/>&#160;
							<vkc:write name="container" property="name"/>
						</td>
						<td nowrap><b><vkc:write name="w" property="name"/></b></td>
						<td nowrap><vkc:write name="w" property="priority"/></td>
						<td nowrap><vkc:write name="w" property="receivedAt" formatKey="date.medium.format"/></td>
						<td nowrap><%--bean:write name="w" property="deadline"/--%></td>
						<td nowrap>
						    <vkc:link href='<%="javascript:openWindow(640,480,'" + ctxPath + "/workflow/visualizeProcess.do?procId=" + container.getId() + "','" + vkc.util.VKCStringUtils.replaceToken(container.getName(), " ", "_") + "');"%>'>
							 	<vkc:img page='/../templates/${template.name}/gfx/wf-view.png' border="0" altKey="wf.visualize_process"/></vkc:link>&#160;
							<vkc:link page="/worklist.do?action=accept" paramId="detailId" paramName="w" paramProperty="id">
								<vkc:img page='/../templates/${template.name}/gfx/wf-accept.png' border="0" altKey="wf.accept"/></vkc:link>&#160;
							<vkc:link page="/worklist.do?action=reassign.display" paramId="detailId" paramName="w" paramProperty="id">
								<vkc:img page='/../templates/${template.name}/gfx/wf-reassign.png' border="0" altKey="wf.reassign"/></vkc:link>
						
						</td>
					</tr>
					<logic:equal parameter="detailId" value="<%=w.getId()%>">
					<%if(index.intValue() % 2 == 0 ) out.print( "<tr>" ); else out.print( "<tr class=\"tablerow\">" );%>
						<td colspan="6" valign="top">
						<b>Beschreibung:</b>
						<logic:empty name="w" property="description">
							---
						</logic:empty>
						<logic:notEmpty name="w" property="description">
							<vkc:write name="w" property="description"/>
						</logic:notEmpty>
						</td>
					</tr>
					<logic:equal parameter="action" value="reassign.display">
					<html:form action="/worklist" method="post">
						<html:hidden property="action" value="reassign.save"/>
						<input type="hidden" name="activityId" value="<%=w.getId()%>" />
						<%if(index.intValue() % 2 == 0 ) out.print( "<tr>" ); else out.print( "<tr class=\"tablerow\">" );%>
							<td valign="top" colspan="6">
							<b>Zuweisen an:</b>
								<html:select name="form" property="newAssigneeName" size="1">
						      		<bean:define id="users" name="form" property="userInfos"/>
						      		<vkc:options collection="users" property="username" labelProperty="fullName"/>
						      	</html:select>
							&#160;
							<vkc:button property="action.reassign" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="wf.button.reassign"/></vkc:button>
							</td>
						</tr>
					</html:form>
					</logic:equal>
					</logic:equal>
				</logic:iterate>
					</table>
					</td>
				</tr>
			</table>
		</td>
  </tr>
</table>
</body>
</html:html>