<%@ 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>

  	<vkc:cssinclude />

    <meta http-equiv="content-type"  content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="<vkc:rewrite page='/common/utils.js'   />"></script>
    <script type="text/javascript" src="<vkc:rewrite page='/common/calendar.js'/>"></script>

    <script type="text/javascript">

    window.name = "MAINVIEW";
    var associatedTabId = <%=TabId.ADMIN_GROUPMANAGEMENT_TAB%>;
    var currentCalendar = null;

    function init() {

        var tabView = getTabView();
        var tabViewForm = tabView.document.forms[0];

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

        <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>
    }

    function unloadPage() {
        if ( currentCalendar!=null ) {
              hideCalendar();
        }
    }

    </script>

</head>
<body onload="init();" onUnload="unloadPage();" topmargin="0" marginheight="0">
<html:form action="/editGroup" method="post">

<bean:define id="form" name="editGroupForm" scope="request" type="vkc.administration.form.EditGroupForm"/>

<html:hidden property="groupId"/>
<html:hidden property="redirect"/>
<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>

<logic:notEmpty name="form" property="groupId">
<bean:define id="groupId" name="form" property="groupId" type="java.lang.Integer"/>
<table width="1%" align="center" cellspacing="3" cellpadding="0" border="0">
    <logic:present name="<%=Globals.ERROR_KEY%>">
      <tr><td align="left" nowrap="nowrap" colspan="5"><font color="red"><b><vkc:errors/></b></font></td></tr>
    <vkc:hline colspan="5" lineClass="hline" lineHeight="1" topSpace="3" bottomSpace="3"/>
    </logic:present>

    <tr>
      <td align="left" nowrap="nowrap" colspan="5"><vkc:message key="mandatory.field1"/>&nbsp;<vkc:img page="/templates/${template.name}/gfx/mandatoryField.gif" alt="*" border="0"/>&nbsp;<vkc:message key="mandatory.field2"/></td>
    </tr>

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

    <tr>
      <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.groups.name" />:</b>&nbsp;<vkc:img page="/templates/${template.name}/gfx/mandatoryField.gif" alt="*" border="0"/></td>
      <td width="100%" align="left"><vkc:text name="form" property="groupname" styleClass="profileField" maxlengthProperty="group.name"/></td>
      <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="1" width="5"/></td>

      <logic:equal name="form" property="accountValid" value="true">
      <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.groups.accountValid.from" />:</b></td>
      <td width="100%" align="left">
        <table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td><html:text property="validFrom" maxlength="10" size="10" styleClass="dateField"/></td>
            <td><vkc:calendarbutton buttonName="btn_validFrom" /></td>
            <td>&nbsp;[<vkc:message key="vkc.profile.date_format"/>]</td>
          </tr>
        </table>
      </td>
      </logic:equal>

      <logic:equal name="form" property="accountValid" value="false">
      <td align="left" nowrap="nowrap"><font style="color:#aaaaaa" ><b><vkc:message key="vkc.administration.groups.accountValid.from" />:</b></font></td>
      <td width="100%" align="left">
        <table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td><html:text property="validFrom" maxlength="10" size="10" styleClass="dateField" disabled="true"/></td>
            <td>&nbsp;<font style="color:#aaaaaa" >[<vkc:message key="vkc.profile.date_format" />]</font></td>
          </tr>
        </table>
      </td>
      </logic:equal>
    </tr>

    <tr>
      <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.groups.accountValid" />:</b></td>
      <td width="100%" align="left"><html:checkbox name="form" property="accountValid" onclick="submit();"/></td>
      <td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="1" width="5"/></td>

      <logic:equal name="form" property="accountValid" value="true">
      <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.groups.accountValid.until" />:</b></td>
      <td width="100%" align="left">
        <table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td><html:text property="validUntil" maxlength="10" size="10" styleClass="dateField"/></td>
            <td><vkc:calendarbutton buttonName="btn_validUntil" /></td>
            <td>&nbsp;[<vkc:message key="vkc.profile.date_format"/>]</td>
          </tr>
        </table>
      </td>
      </logic:equal>

      <logic:equal name="form" property="accountValid" value="false">
      <td align="left" nowrap="nowrap"><font style="color:#aaaaaa" ><b><vkc:message key="vkc.administration.groups.accountValid.until" />:</b></font></td>
      <td width="100%" align="left">
        <table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td><html:text property="validUntil" maxlength="10" size="10" styleClass="dateField" disabled="true"/></td>
            <td>&nbsp;<font style="color:#aaaaaa" >[<vkc:message key="vkc.profile.date_format" />]</font></td>
          </tr>
        </table>
      </td>
      </logic:equal>
    </tr>

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

    <tr>
      <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.groups.description" />:</b></td>
      <td width="100%" align="left"><vkc:text name="form" property="description" styleClass="profileField" maxlengthProperty="group.description"/></td>
    </tr>

    <vkc:hasAdminPrivileges>
    <tr>
      <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.groups.adminprivileges" />:</b></td>
      <td width="100%" align="left"><html:checkbox name="form" property="adminPrivileges" /></td>
    </tr>
    </vkc:hasAdminPrivileges>

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

    <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.administration.groupMembers"/></b></td>
          <td width="1" align="center" nowrap="nowrap"></td>
          <td width="50%" align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.userlist"/>:</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.usersToGroup" 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.usersFromGroup" 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>


	 

  <tr>
    <td colspan="2">    
    <table width=100% border=0 cellpadding=3 cellspacing=1>
      <tr><td width=50%  align=left valign=bottom><b><vkc:message key="vkc.groupinfo.groupCreatedAt" /></b>&nbsp;<vkc:write name="form" property="group.created" formatKey="date.medium.format"/></td></tr>
      <logic:notEmpty name="form" property="creator">
      <tr><td width=50%  align=left valign=bottom><b><vkc:message key="vkc.groupinfo.groupCreatedFrom" /></b>&nbsp;<vkc:write name="form" property="creator.username"/></td></tr>
      </logic:notEmpty>
      <logic:empty name="form" property="creator">
      <tr><td width=50%  align=left valign=bottom><b><vkc:message key="vkc.groupinfo.groupCreatedFrom" /></b>&nbsp;-</td></tr>
      </logic:empty>
    </table>  
    </td>    
  </tr>
  
	<vkc:hline colspan="5" lineClass="hline" lineHeight="1" topSpace="5" bottomSpace="5"/>

  <tr>
    <td colspan="2">    
    <table width=100% border=0 cellpadding=3 cellspacing=1>
      <tr><td width=50%  align=left valign=bottom><b><vkc:message key="vkc.groupinfo.groupLastChangedAt" /></b>&nbsp;<vkc:write name="form" property="group.lastChanged" formatKey="date.medium.format"/></td></tr>
      <logic:notEmpty name="form" property="lastEditor">
      <tr><td width=50%  align=left valign=bottom><b><vkc:message key="vkc.groupinfo.groupLastChangedFrom" /></b>&nbsp;<vkc:write name="form" property="lastEditor.username"/></td></tr>
      </logic:notEmpty>
      <logic:empty name="form" property="lastEditor">
      <tr><td width=50%  align=left valign=bottom><b><vkc:message key="vkc.groupinfo.groupLastChangedFrom" /></b>&nbsp;-</td></tr>
      </logic:empty>
    </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.save.group" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.save"/></vkc:button>
        <vkc:button property="action.back" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="button.back"/></vkc:button>
      </td>
    </tr>
</table>
</logic:notEmpty>
</html:form>
</body>
</html:html>
