<%--
/**
 * 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.
 *
 *
 *
 */
--%>

<commerce-ui:panel
	title='<%= LanguageUtil.get(request, "schedule") %>'
>
	<div class="row">
		<div class="col-6">
			<aui:input formName="fm" label="publish-date" name="displayDate" />
		</div>

		<%
		boolean neverExpire = ParamUtil.getBoolean(request, "neverExpire", true);

		if ((commercePriceEntry != null) && (commercePriceEntry.getExpirationDate() != null)) {
			neverExpire = false;
		}
		%>

		<div class="col-6">
			<liferay-ui:error exception="<%= CommercePriceListExpirationDateException.class %>" message="please-enter-a-valid-expiration-date" />

			<aui:input dateTogglerCheckboxLabel="never-expire" disabled="<%= neverExpire %>" formName="fm" name="expirationDate" />
		</div>
	</div>
</commerce-ui:panel>

<commerce-ui:panel
	title='<%= LanguageUtil.get(request, "price") %>'
>

	<%
	boolean priceOnApplication = BeanParamUtil.getBoolean(commercePriceEntry, request, "priceOnApplication", false);
	%>

	<c:if test='<%= FeatureFlagManagerUtil.isEnabled("COMMERCE-11028") %>'>
		<div class="row">
			<div class="col-12">
				<aui:input checked="<%= priceOnApplication %>" helpMessage="do-not-set-a-base-price-for-this-product" inlineLabel="right" label="price-on-application" name="priceOnApplication" type="toggle-switch" />
			</div>
		</div>
	</c:if>

	<aui:fieldset collapsible="<%= false %>" cssClass='<%= "price-entry-price-settings " + (priceOnApplication ? "disabled" : StringPool.BLANK) %>' id='<%= liferayPortletResponse.getNamespace() + "price-entry-price-settings" %>' label="price-settings">
		<liferay-ui:error exception="<%= CommercePriceListMaxPriceValueException.class %>">
			<liferay-ui:message arguments="<%= CommercePriceConstants.PRICE_VALUE_MAX %>" key="price-max-value-is-x" />
		</liferay-ui:error>

		<%
		boolean discountDiscovery = BeanParamUtil.getBoolean(commercePriceEntry, request, "discountDiscovery", true);
		%>

		<div class="row">
			<div class="col-12">
				<aui:input checked="<%= !discountDiscovery %>" disabled="<%= priceOnApplication %>" helpMessage="override-discount-help" inlineLabel="right" label="override-discount" name="overrideDiscount" type="toggle-switch" />
			</div>

			<div class="col-12">
				<div class="<%= discountDiscovery ? "hide" : StringPool.BLANK %>" id="<portlet:namespace />discountLevels">
					<label class="control-label" for="<portlet:namespace />discountLevel1"><liferay-ui:message key="discount-levels" /></label>

					<div class="row">
						<div class="col-3">
							<aui:input disabled="<%= discountDiscovery || priceOnApplication %>" ignoreRequestValue="<%= true %>" inlineField="<%= true %>" label="l1" name="discountLevel1" type="text" value="<%= commercePriceEntry.getDiscountLevel1() %>" wrapperCssClass="discount-label-wrapper">
								<aui:validator name="min"><%= CommercePriceConstants.PRICE_VALUE_MIN %></aui:validator>
								<aui:validator name="max"><%= CommercePriceConstants.PRICE_VALUE_MAX %></aui:validator>
								<aui:validator name="number" />
							</aui:input>
						</div>

						<div class="col-3">
							<aui:input disabled="<%= discountDiscovery || priceOnApplication %>" ignoreRequestValue="<%= true %>" inlineField="<%= true %>" label="l2" name="discountLevel2" type="text" value="<%= commercePriceEntry.getDiscountLevel2() %>" wrapperCssClass="discount-label-wrapper">
								<aui:validator name="min"><%= CommercePriceConstants.PRICE_VALUE_MIN %></aui:validator>
								<aui:validator name="max"><%= CommercePriceConstants.PRICE_VALUE_MAX %></aui:validator>
								<aui:validator name="number" />
							</aui:input>
						</div>

						<div class="col-3">
							<aui:input disabled="<%= discountDiscovery || priceOnApplication %>" ignoreRequestValue="<%= true %>" inlineField="<%= true %>" label="l3" name="discountLevel3" type="text" value="<%= commercePriceEntry.getDiscountLevel3() %>" wrapperCssClass="discount-label-wrapper">
								<aui:validator name="min"><%= CommercePriceConstants.PRICE_VALUE_MIN %></aui:validator>
								<aui:validator name="max"><%= CommercePriceConstants.PRICE_VALUE_MAX %></aui:validator>
								<aui:validator name="number" />
							</aui:input>
						</div>

						<div class="col-3">
							<aui:input disabled="<%= discountDiscovery || priceOnApplication %>" ignoreRequestValue="<%= true %>" inlineField="<%= true %>" label="l4" name="discountLevel4" type="text" value="<%= commercePriceEntry.getDiscountLevel4() %>" wrapperCssClass="discount-label-wrapper">
								<aui:validator name="min"><%= CommercePriceConstants.PRICE_VALUE_MIN %></aui:validator>
								<aui:validator name="max"><%= CommercePriceConstants.PRICE_VALUE_MAX %></aui:validator>
								<aui:validator name="number" />
							</aui:input>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="row">
			<div class="col-6">
				<aui:input cssClass="base-price" disabled="<%= true %>" label="base-price" name="base-price" type="text" value="<%= commercePriceEntryDisplayContext.getBasePrice() %>" />
			</div>

			<%
			CommercePriceList commercePriceList = commercePriceEntry.getCommercePriceList();

			CommerceCurrency commerceCurrency = commercePriceList.getCommerceCurrency();

			String priceInputLabel = "price-list-price";

			if (CommercePriceListConstants.TYPE_PROMOTION.equals(commercePriceEntryDisplayContext.getCommercePriceListType(portletName))) {
				priceInputLabel = "promotion-price";
			}
			%>

			<div class="col-6">
				<aui:input disabled="<%= priceOnApplication %>" label="<%= priceInputLabel %>" name="price" suffix="<%= HtmlUtil.escape(commerceCurrency.getCode()) %>" type="text" value="<%= commerceCurrency.round(commercePriceEntry.getPrice()) %>">
					<aui:validator name="min"><%= CommercePriceConstants.PRICE_VALUE_MIN %></aui:validator>
					<aui:validator name="max"><%= CommercePriceConstants.PRICE_VALUE_MAX %></aui:validator>
					<aui:validator name="number" />
				</aui:input>
			</div>
		</div>

		<div class="row">
			<div class="col-12">
				<%@ include file="/commerce_price_lists/commerce_price_entry/tier_price_entries.jspf" %>
			</div>
		</div>
	</aui:fieldset>
</commerce-ui:panel>

<liferay-frontend:component
	module="commerce_price_lists/commerce_price_entry/js/PriceEntry"
/>