<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jspf/taglibs.jsp"%>

<c:set var="uiid" value="${u:uiid()}"/>

<div id="${uiid}">
	<html:form action="${form.requestURI}">
		<html:hidden property="method"/>
		<ui:combo-single name="storeId" value="${frd.storeId}" widthTextValue="20em"
			list="${frd.storeList}" showFilter="true"
			onSelect="$$.ajax.load(this.form, $('#${uiid}'), {control: this})">
			<jsp:attribute name="valuesHtml"><li value=""></li></jsp:attribute>
		</ui:combo-single>
	</html:form>

	<c:if test="${frd.storeId gt 0}">
		<p:check action="/admin/plugin/sync1c/instance:importFileForm">
			<c:url var="importCsvUrl" value="/admin/plugin/sync1c/instance.do">
				<c:param name="method" value="importFileForm"/>
				<c:param name="storeId" value="${frd.storeId}"/>
			</c:url>
			<button type="button" class="btn-white btn-small mt05" onclick="$$.ajax.loadContent('${importCsvUrl}')">
				<i class="ti-upload"></i> ${l.l('Загрузить CSV')}</button>
		</p:check>
	</c:if>

	<c:if test="${not empty frd.movementList}">
		<table class="data mt1 hl">
			<tr>
				<td>ID</td>
				<td>${l.l('Дата операции')}</td>
				<td>${l.l('Тип операции')}</td>
				<td>${l.l('Номенклатура')}</td>
				<td>${l.l('Количество')}</td>
				<td>${l.l('Серийный номер')}</td>
				<td>${l.l('Процесс')}</td>
				<td>${l.l('Комментарий')}</td>
			</tr>
			<c:forEach var="m" items="${frd.movementList}">
				<tr>
					<td>${m.id}</td>
					<td class="nowrap">${tu.format(m.dt, 'ymdhms')}</td>
					<td>
						<c:choose>
							<c:when test="${m.type eq 'reserve'}">${l.l('Резерв')}</c:when>
							<c:when test="${m.type eq 'unreserve'}">${l.l('Снятие резерва')}</c:when>
							<c:when test="${m.type eq 'writeoff'}">${l.l('Списание')}</c:when>
							<c:when test="${m.type eq 'receipt'}">${l.l('Приход')}</c:when>
							<c:when test="${m.type eq 'return'}">${l.l('Возврат')}</c:when>
							<c:when test="${m.type eq 'transfer'}">${l.l('Перемещение')}</c:when>
							<c:when test="${m.type eq 'adjustment'}">${l.l('Корректировка')}</c:when>
							<c:otherwise>${m.type}</c:otherwise>
						</c:choose>
					</td>
					<td>${m.itemTitle}</td>
					<td>${m.quantity}</td>
					<td>${m.serialNumber}</td>
					<td>
						<c:if test="${m.processId gt 0}">
							<ui:process-link id="${m.processId}" text="#${m.processId} ${m.processTitle}"/>
						</c:if>
					</td>
					<td>${m.comment}</td>
				</tr>
			</c:forEach>
		</table>
	</c:if>
</div>
