<%@ page language="java" buffer="64kb" %>

<%@ taglib uri="struts-html"     prefix="html"  %>
<%@ taglib uri="struts-bean"     prefix="bean"  %>
<%@ taglib uri="struts-logic"    prefix="logic" %>
<%@ taglib uri="vkc-taglib"      prefix="vkc"   %>

<%@ page import="vkc.db.entities.VKCDocumentStatus" %>
<%@ page import="org.apache.struts.Globals"         %>
<%@ page import="vkc.view.PageId" %>
<%@ page import="vkc.db.entities.VKCCategory" %>

<vkc:init/>

<bean:define id="form" name="form" type="vkc.procoba.function.FunctionalViewForm" scope="request"/>

<tr>
  <td colspan="1">
    <table width="100%" cellpadding="0" cellspacing="5">
      <vkc:hline lineClass="hline" topSpace="0" bottomSpace="0" lineHeight="1" colspan="1" />

      <tr><td align="left"><b><vkc:message key="function.label.documents" />:</b></td></tr>
        
      <logic:empty name="form" property="allFunctionalViewDocuments">
      <tr><td align="left"><vkc:message key="function.label.no.documents"/></td></tr>
      </logic:empty>

      <logic:notEmpty name="form" property="allFunctionalViewDocuments">
      <bean:define id="userDocumentViewSettings" name="documentViewSettings" type="vkc.view.bean.DocumentViewSettings" toScope="request" />
      <%-- Liste der Dokumente --%>
      <logic:iterate id="doc" name="form" property="allFunctionalViewDocuments" type="vkc.db.entities.VKCDocument">
        <bean:define id="documentId" name="doc" property="documentId" type="java.lang.Integer"/>
        <bean:define id="virtualDocument" name="doc" type="vkc.db.entities.VKCDocument" toScope="request" />
        <tr>
          <td class="color_doctitle">
            <a name='doc<vkc:write name="doc" property="documentId"/>'></a>
            <table id='<%=documentId + "a"%>' width="100%" cellspacing="0" cellpadding="0" border="0">
              <tr>
			    <logic:equal name="form" property='<%= "showDocDetails[" + documentId + "]" %>' value="false">
				<td><vkc:link href='<%= "javascript:showDocumentDetails(" + documentId + ");" %>'><vkc:img page="/templates/${template.name}/gfx/plus.gif" border="0" titleKey="vkc.tooltip.show.document.details"/></vkc:link></td>
				</logic:equal>

				<logic:equal name="form" property='<%= "showDocDetails[" + documentId + "]" %>' value="true">
				<td><vkc:link href='<%= "javascript:hideDocumentDetails(" + documentId + ");" %>'><vkc:img page="/templates/${template.name}/gfx/minus.gif" border="0" titleKey="vkc.tooltip.hide.document.details"/></vkc:link></td>
				</logic:equal>
                
                <td width="5" align="right"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt=""  height="24" width="5"/></td>
                <td><vkc:img page='<%="/templates/${template.name}" + doc.getDocumentIcon()%>' alt='' border='0'/></td>
                <td width="5" align="right"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt=""  height="24" width="5"/></td>
                <td width="100%" align="left"><b><vkc:write name="doc" property="header"/></b></td>

          		<logic:notEqual value="<%=VKCCategory.FLAG_CLOSED.toString()%>" name="form" property="category.flag">

                <vkc:hasAdminPrivileges>
                <td><a href="<%=ctxPath%><vkc:write name="doc" property="documentSysLink" />" target="about:blank"><vkc:img border="0" page="/templates/${template.name}/gfx/document-jump.gif" titleKey="vkc.string.jump_to_real_doc"/></a></td>
                <td width="5" align="right"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt=""  height="10" width="5"/></td>
                <td width="2" align="right"><vkc:img page="/templates/${template.name}/gfx/border.gif" alt="|" height="15" width="2"/></td>
                </vkc:hasAdminPrivileges>

			    <!-- Dokument bearbeiten -->
                <vkc:hasPermission context="virtualDocument" requiredPerm="w">
                <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="10" width="5"/></td>
                <td><vkc:link page='<%= form.getEditDocumentLink() %>' paramId="documentId" paramName="doc" paramProperty="documentId">
                <vkc:img border="0" page="/templates/${template.name}/gfx/button-editdocument.gif" alt="" titleKey="vkc.tooltip.editdocument" onclick="this.blur();"/>
                </vkc:link></td>
                </vkc:hasPermission>

                <!-- Neue Version -->
                <vkc:hasPermission context="virtualDocument" requiredPerm="w">
                <bean:define id="lockUserInfo" name="form" property='<%="lockUserInfo(" + documentId + ")"%>' type="java.lang.String"/>
                <logic:notEqual name="lockUserInfo" value="">
                <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="10" width="10"/></td>
                <td><vkc:img page="/templates/${template.name}/gfx/document-locked.gif" border="0" title='<%= lockUserInfo %>'/></td>
                </logic:notEqual>
                <logic:equal name="lockUserInfo" value="">
                <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="10" width="10"/></td>
                <td><vkc:link page='<%= form.getNewDocumentVersionLink() %>' name="doc" property="newVersionLinkParams">
                <vkc:img border="0" page="/templates/${template.name}/gfx/button-newversion.gif" alt="" titleKey="vkc.tooltip.addversion" onclick="this.blur();"/>
                </vkc:link></td>
                </logic:equal>
                </vkc:hasPermission>

                </logic:notEqual>

                <!-- Versionsübersicht -->
                <logic:notEmpty name="doc" property="preDocId">
                <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="10" width="10"/></td>
                <td><vkc:link page='<%= form.getShowDocumentVersionsLink() %>' paramId="documentId" paramName="doc" paramProperty="documentId" onfocus="this.blur();">
                <vkc:img border="0" page="/templates/${template.name}/gfx/button-showallversions.gif" alt="" titleKey="vkc.tooltip.showallversions"/>
                </vkc:link></td>
                </logic:notEmpty>
                
          		<logic:notEqual value="<%=VKCCategory.FLAG_CLOSED.toString()%>" name="form" property="category.flag">

                <!-- Löschen -->
                <vkc:hasPermission context="virtualDocument" requiredPerm="d">
                <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="10" width="6"/></td>
                <td><vkc:link href='<%="javascript:deleteDocument(" + documentId + ")"%>'><vkc:img border="0" page="/templates/${template.name}/gfx/button-deletedocument.gif" alt="" titleKey="vkc.tooltip.delete.this.doc"/></vkc:link></td>
                </vkc:hasPermission>

                </logic:notEqual>

                <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="10" width="5"/></td>
                <td align="right"><vkc:img page="/templates/${template.name}/gfx/border.gif" alt="|" height="15" width="2"/></td>
                <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="10" width="5"/></td>
        
                <td width="100%" align="right"><a href="#top" onclick="this.blur();"><vkc:img page="/templates/${template.name}/gfx/button-top.gif" border="0" alt="" titleKey="vkc.tooltip.gototop"/></a></td>
                <td width="5" align="right"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt=""  height="24" width="5"/></td>
              </tr>
            </table>
          </td>
        </tr>
        
        <bean:define id="displayCategoryPath" type="java.lang.String" value="false" toScope="request"/>
        <bean:define id="document" name="doc" type="vkc.db.entities.VKCDocument" toScope="request" />
      	<bean:define id="currentUser" name="form" property="user" type="vkc.db.entities.VKCUser" toScope="request"/>
		
		<logic:equal name="form" property='<%= "showDocDetails[" + documentId + "]" %>' value="true">
	    <bean:define id="documentViewSettings" name="documentViewSettings" property="fullviewDocumentViewSettings" type="vkc.view.bean.DocumentViewSettings" toScope="request" />
		</logic:equal>          
		<logic:equal name="form" property='<%= "showDocDetails[" + documentId + "]" %>' value="false">
	    <bean:define id="documentViewSettings" name="userDocumentViewSettings" type="vkc.view.bean.DocumentViewSettings" toScope="request" />
	    </logic:equal>          
        
        <bean:define id="rowId" value="true" type="java.lang.String" toScope="request" />
   		<jsp:include page='<%="/templates/" + template + "/common/DocumentView.jsp"%>'/>
      </logic:iterate>
      </logic:notEmpty>
    </table>
  </td>
</tr>
