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

        var form = document.forms[ 0 ];
        form.name.focus();
    }

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

    </script>

</head>
<body onload="init();" onUnload="unloadPage();" topmargin="0" marginheight="0">
<table width="100%" cellspacing="1" cellpadding="5" border="0">
  <html:form action="/newGroup" method="post">

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

  <tr><td><vkc:img page="/templates/${template.name}/gfx/trans.gif" alt="" height="3" width="30"/></td></tr>

  <tr>
    <td width="100%" align="center">
      <table width="400" align="center" cellpadding="0" cellspacing="5" border="0">
        <logic:present name="<%=Globals.ERROR_KEY%>">
        <tr><td align="left" nowrap="nowrap" colspan="2"><font color="red"><b><vkc:errors/></b></font></td></tr>
        </logic:present>

        <tr>
            <td width="0" align="left" nowrap="nowrap" colspan="2"><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="2" lineClass="hline" lineHeight="1" topSpace="0" bottomSpace="0"/>

        <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 property="name" styleClass="inputField" maxlengthProperty="group.name"/></td>
        </tr>

        <tr>
          <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.groups.description" />:</b></td>
          <td width="100%" align="left"><vkc:text property="description" styleClass="inputField" 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 property="adminprivileges"/></td>
        </tr>
        </vkc:hasAdminPrivileges>

        <tr>
          <td align="left" nowrap="nowrap"><b><vkc:message key="vkc.administration.groups.accountValid" />:</b></td>
          <td width="100%" align="left"><html:checkbox property="groupActive" onclick="submit();"/></td>
        </tr>

        <logic:equal name="form" property="groupActive" value="true">
        <tr>
          <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>
          </tr>

        <tr>
          <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>
          </tr>
          </logic:equal>

        <logic:equal name="form" property="groupActive" value="false">
        <tr>
          <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><font style="color:#aaaaaa">&nbsp;[<vkc:message key="vkc.profile.date_format" />]</font></td>
              </tr>
            </table>
          </td>
          </tr>

        <tr>
          <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><font style="color:#aaaaaa">&nbsp;[<vkc:message key="vkc.profile.date_format" />]</font></td>
              </tr>
            </table>
          </td>
          </tr>
          </logic:equal>

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

        <tr>
          <td align="center" colspan="2">
            <vkc:button property="action.create.group" onclick="javascript:disableAllButtonsAndSubmit(this);"><vkc:message key="vkc.administration.button.createGroup"/></vkc:button>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  </html:form>
</table>
</body>
</html:html>
