<%@ page import="vkc.view.PageId" %>
<%@ 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.db.entities.VKCCategory" %>

<vkc:init/>

<bean:define id="form" name="form" type="vkc.procoba.project.ProjectViewForm" scope="request"/>
<bean:define id="subfolder" name="form" property="subfolder"/>

<tr>
  <td colspan="1">
    <table cellpadding="0" cellspacing="5" width="100%">

      <vkc:hline lineClass="hline" topSpace="0" bottomSpace="0" lineHeight="1" colspan="1" />

      <tr><td align="left"><b><vkc:message key="project.label.documents" />:</b></td></tr>

        <logic:empty name="subfolder" property="documents">
          <tr><td align="left"><vkc:message key="project.label.no.documents"/></td></tr>
        </logic:empty>

        <logic:notEmpty name="subfolder" property="documents">

  		  <bean:define id="userDocumentViewSettings" name="documentViewSettings" type="vkc.view.bean.DocumentViewSettings" toScope="request" />
          <%-- Liste der Dokumente --%>
          <logic:iterate id="doc" name="form" property="documents" type="vkc.db.entities.VKCDocument">

            <bean:define id="documentId" name="doc" property="documentId" type="java.lang.Integer"/>

            <tr>
              <td class="color_doctitle">
                <a name='doc<vkc:write name="doc" property="documentId"/>'></a>
                <table id='<%=documentId + "a"%>' cellspacing="0" cellpadding="0" width="100%" 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 align="left" width="100%"><b><vkc:write name="doc" property="header"/></b></td>

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

                    <!-- Dokument bearbeiten -->
                    <vkc:hasPermission context="subfolder" requiredPerm="w">
                    <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="10" width="10"/></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="subfolder" 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="project.flag">

                    <!-- Löschen -->
                    <vkc:hasPermission context="subfolder" 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 width="1" align="right"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt=""  height="24" width="5"/></td>
                    <td width="2" align="right"><vkc:img page="/templates/${template.name}/gfx/border.gif" alt="|" height="15" width="2"/></td>
                    <td width="1" align="right"><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt=""  height="24" 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="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>
