<%--
 * Copyright by Intland Software
 *
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Intland Software. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Intland.
 *
 * $Revision$ $Date$
--%>

<%@ taglib uri="jstl-c" prefix="c" %>
<%@ taglib uri="jstl-fmt" prefix="fmt" %>

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


<%@ taglib uri="acltaglib" prefix="acl" %>
<%@ taglib uri="charttaglib" prefix="chart" %>
<%@ taglib uri="uitaglib" prefix="ui" %>

<%
	pageContext.setAttribute("lineBreak", "<TR><TD>&nbsp;</TD></TR>", PageContext.REQUEST_SCOPE);
%>

<c:set var="user" value="${pageContext.request.userPrincipal}" />

<c:set var="user_id" value="${user.id}" />

<c:forEach items="${paramValues.proj_id}" var="pr_id" varStatus="status">
	<c:set var="proj_ids" value="${proj_ids}${pr_id}" />
	<c:if test="${!status.last}">
		<c:set var="proj_ids" value="${proj_ids}," />
	</c:if>
</c:forEach>

<c:if test="${empty proj_ids}">
	<c:set var="proj_ids" value="${PROJECT_DTO.id}" />
</c:if>

<c:set var="proj_id" value="${proj_ids}" scope="request" />

<c:set var="geometry" value="${param.geometry}" />
<c:choose>
	<c:when test="${geometry == 'tight'}">
		<c:set var="whtd" value="450" scope="request" />
		<c:set var="hght" value="250" scope="request" />
	</c:when>

	<c:when test="${geometry == 'wide'}">
		<c:set var="whtd" value="750" scope="request" />
		<c:set var="hght" value="400" scope="request" />
	</c:when>

	<c:otherwise>
		<c:set var="whtd" value="600" scope="request" />
		<c:set var="hght" value="300" scope="request" />
	</c:otherwise>
</c:choose>

<html:errors />

<c:if test="${!empty param.action}">
	<c:set var="action" value="${param.action}" />
</c:if>

<html:form action="${action}">
	<jsp:useBean id="projectChartDateSelectorForm" class="com.intland.codebeamer.struts.ProjectChartDateSelectorForm" scope="session" />

	<c:set var="parseDatePattern" value="yyyy-MM-dd" />
	<c:set var="formatDatePattern" value="yyyyMMdd" scope="request" />

	<c:catch>
		<fmt:parseDate var="startDate" value="${projectChartDateSelectorForm.map.startDate}"
			scope="request" pattern="${parseDatePattern}" parseLocale="en" />
	</c:catch>

	<c:catch>
		<fmt:parseDate var="closeDate" value="${projectChartDateSelectorForm.map.closeDate}"
			scope="request" pattern="${parseDatePattern}" parseLocale="en" />
	</c:catch>

	<html:hidden property="action" value="${action}" />
	<c:forTokens items="${proj_id}" delims="," var="pid" varStatus="status">
		<html:hidden property="proj_id" value="${pid}" />
	</c:forTokens>

	<span class="titlenormal" style="margin-left: 1em;">Period</span>

	<%-- get the duration from the dyna-action-form --%>
	<c:set var="duration" value='<%= projectChartDateSelectorForm.get("duration")%>' />
	<ui:duration property="duration" value="${duration}">
		<span class="titlenormal" style="margin-left: 1em;">Start</span>
		<html:text property="startDate" size="12" styleId="startDate"/>
		<ui:calendarPopup textFieldId="startDate" otherFieldId="closeDate"/>

		<span class="titlenormal" style="margin-left: 1em;">End</span>
		<html:text property="closeDate" size="12" styleId="closeDate" />
		<ui:calendarPopup textFieldId="closeDate" otherFieldId="startDate"/>
	</ui:duration>

	<span class="titlenormal" style="margin-left: 1em;">Geometry</span>
	<html:select property="geometry">
		<html:option value="tight">Tight</html:option>
		<html:option value="normal">Normal</html:option>
		<html:option value="wide">Wide</html:option>
	</html:select>

	&nbsp;&nbsp;<html:submit styleClass="button" property="GO" value="GO" />

</html:form>
