<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
--%>

<aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= (commerceInventoryReplenishmentItem == null) ? Constants.ADD : Constants.UPDATE %>" />
<aui:input name="redirect" type="hidden" value="<%= currentURL %>" />
<aui:input name="commerceInventoryReplenishmentItemId" type="hidden" value="<%= commerceInventoryDisplayContext.getCommerceInventoryReplenishmentItemId() %>" />
<aui:input name="sku" type="hidden" value="<%= commerceInventoryDisplayContext.getSku() %>" />
<aui:input name="mvccVersion" type="hidden" value="<%= (commerceInventoryReplenishmentItem == null) ? 0 : commerceInventoryReplenishmentItem.getMvccVersion() %>" />

<aui:model-context bean="<%= commerceInventoryReplenishmentItem %>" model="<%= CommerceInventoryReplenishmentItem.class %>" />

<aui:input name="quantity" required="<%= true %>">
	<aui:validator name="min">1</aui:validator>
</aui:input>

<c:if test="<%= commerceInventoryReplenishmentItem == null %>">
	<aui:select label="destination" name="commerceInventoryWarehouseId" required="<%= true %>">

		<%
		List<CommerceInventoryWarehouse> commerceInventoryWarehouses = commerceInventoryDisplayContext.getCommerceInventoryWarehouses();

		for (CommerceInventoryWarehouse commerceInventoryWarehouse : commerceInventoryWarehouses) {
		%>

			<aui:option label="<%= HtmlUtil.escape(commerceInventoryWarehouse.getName()) %>" value="<%= commerceInventoryWarehouse.getCommerceInventoryWarehouseId() %>" />

		<%
		}
		%>

	</aui:select>
</c:if>

<%
Calendar startCalendar;

if (commerceInventoryReplenishmentItem == null) {
	startCalendar = Calendar.getInstance();
}
else {
	Date availabilityDate = commerceInventoryReplenishmentItem.getAvailabilityDate();

	startCalendar = CalendarFactoryUtil.getCalendar(availabilityDate.getTime(), user.getTimeZone());
}
%>

<label><liferay-ui:message key="expected-delivery-date" /></label>
<liferay-ui:input-date
	dayParam="dateDay"
	dayValue="<%= startCalendar.get(Calendar.DATE) %>"
	disabled="<%= false %>"
	firstDayOfWeek="<%= startCalendar.getFirstDayOfWeek() - 1 %>"
	monthParam="dateMonth"
	monthValue="<%= startCalendar.get(Calendar.MONTH) %>"
	name="date"
	required="<%= true %>"
	yearParam="dateYear"
	yearValue="<%= startCalendar.get(Calendar.YEAR) %>"
/>