<%@ page language="java" %>
<%@ include file="inc/taglib.inc.jsp" %>
<%@ include file="inc/helper.inc.jsp" %>
<vkc:init/>
<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">

	function init() {
	    setAnchor();
	}

    function setAnchor() {
        <logic:present parameter="anchor">
            <bean:parameter id="anchor2" name="anchor"/>
            this.location.hash = '<%=anchor2%>';
        </logic:present>
    }

	<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></td><td align="left"><h2><vkc:message key="wf.my_workflows"/></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="instances"/>
	</jsp:include>
	</td>
		<td width="100%" align="center" valign="center">
<!-- Open Workflows -->
		<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 colspan="5" align="left"><b><vkc:message key="wf.active_workflows"/></b></td></tr>
			      		<tr><td colspan="5"><hr size="1" noshade="noshade" width="100%" /></td></tr>
<!-- Messages -->
			      	<jsp:include page="inc/messages.inc.jsp">
		      			<jsp:param name="colspan" value="5"/>
		      		</jsp:include>
					<tr>
						<td class="tableheader">Name</td>
						<td class="tableheader">Prio</td>
						<td class="tableheader">Gestartet am</td>
						<td class="tableheader">Bearbeiter</td>
						<td class="tableheader">Aktionen</td>
					</tr>
				<logic:iterate id="p" name="open.workflows" indexId="index" type="vkc.workflow.model.ProcessInstanceInfo">
				<form name="ID<%=p.getId()%>" action="<%=ctxPath%>/workflow/instances.do">
					<logic:equal name="p" property="state" value="<%=WfConstants.STATE_OPEN_NOT_RUNNING_NOT_STARTED%>">
					<input type="hidden" name="action" value="startProcess" />
					</logic:equal>
					<logic:notEqual name="p" property="state" value="<%=WfConstants.STATE_OPEN_NOT_RUNNING_NOT_STARTED%>">
					<input type="hidden" name="action" value="updateVariables" />
					</logic:notEqual>
					
					<input type="hidden" name="procId" value="<%=p.getId()%>" />
						
					<%if(index.intValue() % 2 == 0 ) out.print( "<tr>" ); else out.print( "<tr class=\"tablerow\">" );%>
						<td nowrap valign="top">
						<a name="<%=p.getId()%>"></a>
						<logic:notEqual parameter="detailId" value="<%=p.getId()%>">
							<vkc:link page="/instances.do" paramId="detailId" paramName="p" paramProperty="id">
								<vkc:img page='/../templates/${template.name}/gfx/plus.gif' border="0" alt="Details"/>
							</vkc:link>
						</logic:notEqual>
						<logic:equal parameter="detailId" value="<%=p.getId()%>">
							<vkc:link page="/instances.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"/></a>&#160;
							<vkc:write name="p" property="name"/>
						</td>
						<td nowrap><vkc:write name="p" property="priority"/></td>
						<td nowrap><vkc:write name="p" property="startTime" formatKey="date.medium.format"/></td>
						<td nowrap><vkc:write name="p" property="processors"/></td>
						<td nowrap>
						   <vkc:link href='<%="javascript:openWindow(640,480,"+"'" + ctxPath + "/workflow/visualizeProcess.do?procId=" + p.getId() + "','" + vkc.util.VKCStringUtils.replaceToken(p.getName(), " ", "_") + "');" %>'>
							 	<vkc:img page='/../templates/${template.name}/gfx/wf-view.png' border="0" altKey="wf.visualize_process"/></vkc:link>&#160;
							<vkc:link page="/instances.do?action=abortProcess" paramId="procId" paramName="p" paramProperty="id"><vkc:img page='/../templates/${template.name}/gfx/wf-close.png' border="0" alt=""/></vkc:link>
						</td>
					</tr>
					<logic:equal parameter="detailId" value="<%=p.getId()%>">
					<%if(index.intValue() % 2 == 0 ) out.print( "<tr>" ); else out.print( "<tr class=\"tablerow\">" );%>					
						<td colspan="5">
						<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">
							<logic:notEmpty name="p" property="description">
							<tr><td valign="top"><b>Beschreibung:</b></td><td colspan="2"><vkc:write name="p" property="description"/></td><tr>
							</logic:notEmpty>
<!-- process.context -->
							<logic:notEmpty name="process.context">
							<tr class="tableheader"><td>Name</td><logic:equal name="instancesForm" property="showDataTypes" value="true"><td>Typ</td></logic:equal><td>Wert</td></tr>
							</logic:notEmpty>
							<logic:iterate id="var" name="process.context" type="vkc.workflow.model.VariableInfo">
								<%@ include file="inc/variables.inc.jsp" %>
							</logic:iterate>
						</table>
						</td>
					</tr>
					<tr>
						<td colspan="5" align="right">
						 	<logic:equal name="p" property="state" value="<%=WfConstants.STATE_OPEN_NOT_RUNNING_NOT_STARTED%>">
							<vkc:button property="action.startProcess" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="wf.button.startProcess"/></vkc:button>
							</logic:equal>
							<logic:notEqual name="p" property="state" value="<%=WfConstants.STATE_OPEN_NOT_RUNNING_NOT_STARTED%>">
							<vkc:button property="action.save" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="wf.button.save"/></vkc:button>
							</logic:notEqual>
						</td>
					</tr>
					</logic:equal>
					</form>
				</logic:iterate>
<!-- closed.completed -->				
						<tr><td colspan="5">&#160;</td></tr>
						<tr><td colspan="5" align="left"><b><vkc:message key="wf.complete_workflows"/></b> (<vkc:link page="/instances.do?action=deleteClosed"><vkc:img page='/../templates/${template.name}/gfx/wf-close.png' border="0" alt=""/></vkc:link>)</td></tr>
			      		<tr><td colspan="5"><hr size="1" noshade="noshade" width="100%" /></td></tr>
<!-- Fehlermeldungen -->
			      		<jsp:include page="inc/error.inc.jsp">
		      				<jsp:param name="colspan" value="5"/>
		      			</jsp:include>
			      		<tr>
							<td class="tableheader">Name</td>
							<td class="tableheader">Prio</td>
							<td class="tableheader">Beendet am</td>
							<td class="tableheader">&#160;</td>
							<td class="tableheader">Aktionen</td>
						</tr>
			      	<logic:iterate id="p" name="closed.completed" indexId="index" 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="<%=p.getId()%>">
							<vkc:link page="/instances.do" paramId="detailId" paramName="p" paramProperty="id">
								<vkc:img page='/../templates/${template.name}/gfx/plus.gif' border="0" alt="Details"/>
							</vkc:link>
						</logic:notEqual>
						<logic:equal parameter="detailId" value="<%=p.getId()%>">
							<vkc:link page="/instances.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"/></a>&#160;
							<vkc:write name="p" property="name"/>
						</td>
						<td nowrap><vkc:write name="p" property="priority"/></td>
						<td nowrap><vkc:write name="p" property="endTime" formatKey="date.medium.format"/></td>
						<td nowrap>&#160;</td>
						<td nowrap>
						<vkc:link href='<%="javascript:openWindow(640,480,'" + ctxPath + "/workflow/visualizeProcess.do?procId=" + p.getId() + "','" + vkc.util.VKCStringUtils.replaceToken(p.getName(), " ", "_") + "');"%>'>
							 	<vkc:img page='/../templates/${template.name}/gfx/wf-view.png' border="0" altKey="wf.visualize_process"/></vkc:link>&#160;
						<vkc:link page="/instances.do?action=deleteClosed" paramId="procId" paramName="p" paramProperty="id"><vkc:img page='/../templates/${template.name}/gfx/wf-close.png' border="0" alt=""/></vkc:link></td>
					</tr>
					<logic:equal parameter="detailId" value="<%=p.getId()%>">
					<%if(index.intValue() % 2 == 0 ) out.print( "<tr>" ); else out.print( "<tr class=\"tablerow\">" );%>					
						<td colspan="5">
						<table width="100%" cellspacing="0" cellpadding="2" border="0" align="center">
							<logic:notEmpty name="p" property="description">
							<tr><td valign="top"><b>Beschreibung:</b></td><td colspan="2"><vkc:write name="p" property="description"/></td><tr>
							</logic:notEmpty>
<!-- process.context -->
							<logic:notEmpty name="process.context">
							<tr class="tableheader"><td>Name</td><logic:equal name="instancesForm" property="showDataTypes" value="true"><td>Typ</td></logic:equal><td>Wert</td></tr>
							</logic:notEmpty>
							<logic:iterate id="var" name="process.context" type="vkc.workflow.model.VariableInfo">
								<%@ include file="inc/variables.inc.jsp" %>
							</logic:iterate>
						</table>
						</td>
					</tr>
					</logic:equal>
				</logic:iterate>
					</table>
					</td>
				</tr>
			</table>
		</td>
  </tr>
</table>
</body>
</html:html>