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

<%@ include file="/init.jsp" %>

<%
CommerceOrderContentDisplayContext commerceOrderContentDisplayContext = (CommerceOrderContentDisplayContext)request.getAttribute(WebKeys.PORTLET_DISPLAY_CONTEXT);

CommerceOrder commerceOrder = commerceOrderContentDisplayContext.getCommerceOrder();
%>

<div class="b2b-portlet-content-header">
	<div class="autofit-float autofit-row header-title-bar">
		<div class="autofit-col autofit-col-expand">
			<liferay-ui:header
				backURL="<%= redirect %>"
				title='<%= LanguageUtil.format(request, "order-x", commerceOrder.getCommerceOrderId()) %>'
			/>
		</div>
	</div>
</div>

<div class="taglib-discussion">

	<%
	Format dateFormatDateTime = FastDateFormatFactoryUtil.getDateTime(locale, timeZone);

	for (CommerceOrderNote commerceOrderNote : commerceOrderContentDisplayContext.getCommerceOrderNotes(commerceOrder)) {
	%>

		<article class="commerce-panel">
			<div class="commerce-panel__content">
				<div class="panel-body">
					<div class="card-row">
						<div class="card-col-content">
							<div class="lfr-discussion-details">
								<liferay-ui:user-portrait
									cssClass="user-icon-lg"
									userId="<%= commerceOrderNote.getUserId() %>"
									userName="<%= commerceOrderNote.getUserName() %>"
								/>
							</div>

							<div class="lfr-discussion-body">
								<div class="lfr-discussion-message">
									<header class="lfr-discussion-message-author">

										<%
										User noteUser = commerceOrderNote.getUser();
										%>

										<aui:a cssClass="author-link" href="<%= ((noteUser != null) && noteUser.isActive()) ? noteUser.getDisplayURL(themeDisplay) : null %>">
											<%= HtmlUtil.escape(commerceOrderNote.getUserName()) %>

											<c:if test="<%= commerceOrderNote.getUserId() == user.getUserId() %>">
												(<liferay-ui:message key="you" />)
											</c:if>
										</aui:a>

										<c:if test="<%= commerceOrderNote.isRestricted() %>">
											<aui:icon image="lock" markupView="lexicon" message="private" />
										</c:if>

										<%
										Date createDate = commerceOrderNote.getCreateDate();
										%>

										<span class="small">
											<liferay-ui:message arguments="<%= LanguageUtil.getTimeDescription(request, System.currentTimeMillis() - createDate.getTime(), true) %>" key="x-ago" translateArguments="<%= false %>" />

											<c:if test="<%= createDate.before(commerceOrderNote.getModifiedDate()) %>">
												<strong onmouseover="Liferay.Portal.ToolTip.show(this, '<%= HtmlUtil.escapeJS(dateFormatDateTime.format(commerceOrderNote.getModifiedDate())) %>');">
													- <liferay-ui:message key="edited" />
												</strong>
											</c:if>
										</span>
									</header>

									<div class="lfr-discussion-message-body">
										<%= HtmlUtil.escape(commerceOrderNote.getContent()) %>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</article>

	<%
	}
	%>

</div>