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

<%@ page language="java" buffer="100kb" errorPage="/common/error.jsp"%>
<%@ page import="vkc.view.WebShare" %>


<%@ page import="vkc.view.TabId" %>
<%@ page import="org.apache.struts.Globals" %>

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

<vkc:checkLogin />
<vkc:init/>
<html:html locale="true">
<head>
    <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 />

    <script type="text/javascript" src="<vkc:rewrite page='/common/calendar.js'/>"></script>
    <script type="text/javascript" src="<vkc:rewrite page='/common/utils.js'/>"></script>

    <script type="text/javascript">
    window.name = "MAINVIEW";
    var currentCalendar = null;

    function init(){
        <logic:present name="<%=WebShare.INFO_KEY%>" scope="request">
          <bean:define id="msg" type="java.lang.String" scope="request" name="<%=WebShare.INFO_KEY%>"/>
          alert( '<vkc:message javascript="true" filter="false" key="<%=msg%>"/>' );
        </logic:present>

        setAnchor();
    }

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

    function unloadPage() {
        if ( currentCalendar != null ) {
              hideCalendar();
        }
    }
	
    </script>
</head>
<body onload="init();" onUnload="unloadPage();" topmargin="0" marginheight="0">
<bean:define id="form" name="registerGroupForm" scope="request" type="vkc.view.form.RegisterGroupForm"/>
<html:form action="/registerGroup" method="post">
<logic:notEmpty name="form" property="categoryId">
  <html:hidden property="categoryId"/>
</logic:notEmpty>
<logic:notEmpty name="form" property="documentId">
  <html:hidden property="documentId"/>
</logic:notEmpty>


<logic:iterate id="gid" name="form" property="addGroupIds" type="java.lang.Integer">
  <html:hidden property="addGroupIds" name="form" value='<%=String.valueOf(gid.toString())%>'/>
</logic:iterate>

<logic:iterate id="uid" name="form" property="addUserIds" type="java.lang.Integer">
  <html:hidden property="addUserIds" name="form" value='<%=String.valueOf(uid.toString())%>'/>
</logic:iterate>

<table width="50%" align="center" cellspacing="3" cellpadding="0" border="0">
  <tr>
    <td align="center" colspan="5">
      <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <logic:equal name="form" property="registerCategory" value="true">
          <td width="100%" align="center" nowrap="nowrap" colspan="4"><b><vkc:message key="vkc.admin.registerGroup.category"/></b></td>
          </logic:equal>
          <logic:equal name="form" property="registerDocument" value="true">
          <td width="100%" align="center" nowrap="nowrap" colspan="4"><b><vkc:message key="vkc.admin.registerGroup.document"/></b></td>
          </logic:equal>
        </tr>
        
        <vkc:hline colspan="4" lineClass="hline" lineHeight="1" topSpace="5" bottomSpace="5"/>
        
        <tr>
          <td align="left" valign="top" nowrap="nowrap"><b><vkc:message key="vkc.category"/>:</b></td>
          <td align="left" valign="top" nowrap="nowrap">&nbsp;</td>
          <td width="100%" align="left" valign="top" colspan="2"><vkc:write name="form" property="category.absPathDescrString"/></td>
        </tr>

        <logic:equal name="form" property="registerDocument" value="true">
        <tr>
          <td align="left" valign="top" nowrap="nowrap"><b><vkc:message key="vkc.title"/>:</b></td>
          <td align="left" valign="top" nowrap="nowrap">&nbsp;</td>
          <td align="left" valign="top" nowrap="nowrap"><vkc:img page='<%="/templates/" + template + form.getDocument().getDocumentIcon()%>' border='0' alt=''/></td>
          <td width="100%" valign="top" align="left"><vkc:write name="form" property="document.title"/></td>
        </tr>
        </logic:equal>
	  </table>
	</td>
  </tr>
  
  <vkc:hline colspan="5" lineClass="hline" lineHeight="1" topSpace="5" bottomSpace="5"/>

  <tr>
    <td align="center" colspan="5">
      <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td width="50%" align="left" nowrap="nowrap"><b><vkc:message key="vkc.admin.registerGroup.groupsToRegister"/>:</b></td>
          <td width="1" align="center" nowrap="nowrap"></td>
          <td width="50%" align="left" nowrap="nowrap"><b><vkc:message key="vkc.admin.registerGroup.groups"/>:</b></td>
        </tr>
        <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="3" width="1"/></td></tr>
        <tr>
          <td width="50%" align="center" nowrap="nowrap">
            <bean:define id="addGroupLabels" name="form" property="addGroupLabels" type="java.util.List"/>
            <html:select name="form" property="selectedRemoveGroupIds" multiple="true" size="10" style="width:99%;">
            <vkc:options collection="addGroupLabels" property="groupId" labelProperty="name"/>
            </html:select>
          </td>
		
		  <td width="1" align="center" nowrap="nowrap">
            <table width="1" align="center" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <td align="center" nowrap="nowrap">&nbsp;<vkc:button property="action.add.groupToRegister" onclick="javascript:disableAllButtonsAndSubmit(this);">&lt;&lt;</vkc:button>&nbsp;</td>
              </tr>

              <tr><td align="center">&nbsp;</td></tr>

              <tr>
                <td align="center" nowrap="nowrap">&nbsp;<vkc:button property="action.remove.groupFromRegister" onclick="javascript:disableAllButtonsAndSubmit(this);">&gt;&gt;</vkc:button>&nbsp;</td>
              </tr>
            </table>
          </td>

          <td width="50%" align="center" nowrap="nowrap">
            <bean:define id="removeGroupLabels" name="form" property="removeGroupLabels" type="java.util.List"/>
            <html:select name="form" property="selectedAddGroupIds" multiple="true" size="10" style="width:99%;">
            <vkc:options collection="removeGroupLabels" property="groupId" labelProperty="name"/>
            </html:select>
          </td>
        </tr>      
      </table>
    </td>
  </tr>
  
  <tr>
    <td align="center" colspan="5">
      <table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td width="50%" align="left" nowrap="nowrap"><b><vkc:message key="vkc.admin.registerGroup.groupsToRegister"/>:</b></td>
          <td width="1" align="center" nowrap="nowrap"></td>
          <td width="50%" align="left" nowrap="nowrap"><b><vkc:message key="vkc.admin.registerGroup.users"/>:</b></td>
        </tr>
        <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="3" width="1"/></td></tr>
        <tr>
          <td width="50%" align="center" nowrap="nowrap">
            <bean:define id="addUserLabels" name="form" property="addUserLabels" type="java.util.List"/>
            <html:select name="form" property="selectedRemoveUserIds" multiple="true" size="10" style="width:99%;">
            <vkc:options collection="addUserLabels" property="userId" labelProperty="lastnameLabel"/>
            </html:select>
          </td>
		
		  <td width="1" align="center" nowrap="nowrap">
            <table width="1" align="center" cellpadding="0" cellspacing="0" border="0">
              <tr>
                <td align="center" nowrap="nowrap">&nbsp;<vkc:button property="action.add.userToRegister" onclick="javascript:disableAllButtonsAndSubmit(this);">&lt;&lt;</vkc:button>&nbsp;</td>
              </tr>

              <tr><td align="center">&nbsp;</td></tr>

              <tr>
                <td align="center" nowrap="nowrap">&nbsp;<vkc:button property="action.remove.userFromRegister" onclick="javascript:disableAllButtonsAndSubmit(this);">&gt;&gt;</vkc:button>&nbsp;</td>
              </tr>
            </table>
          </td>

          <td width="50%" align="center" nowrap="nowrap">
            <bean:define id="removeUserLabels" name="form" property="removeUserLabels" type="java.util.List"/>
            <html:select name="form" property="selectedAddUserIds" multiple="true" size="10" style="width:99%;">
            <vkc:options collection="removeUserLabels" property="userId" labelProperty="lastnameLabel"/>
            </html:select>
          </td>
        </tr>      
      </table>
    </td>
  </tr>

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

  <tr>
    <td align="center" colspan="5">
      <vkc:button property="action.register" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.registerGroup"/></vkc:button>
      <vkc:button property="action.back" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.back"/></vkc:button>
    </td>
  </tr>
</table>
</html:form>
</body>
</html:html>
