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

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

<html:form action="${form.requestURI}">
	<html:hidden property="method"/>
	<ui:toggle name="showDeleted" value="${frd.showDeleted}" prefixText="${l.l('Показать удалённые')}"
		onChange="$$.ajax.loadContent(this.form, this)"/>
</html:form>

<p:check action="/admin/plugin/inventory/item:itemGet">
	<c:url var="addUrl" value="${form.requestURI}">
		<c:param name="method" value="itemGet"/>
		<c:param name="returnUrl" value="${form.requestUrl}"/>
	</c:url>
	<ui:button type="add" onclick="$$.ajax.loadContent('${addUrl}', this)"/>
</p:check>

<table id="${uiid}" class="data mt1 hl">
	<tr>
		<td width="30">&#160;</td>
		<td width="40">ID</td>
		<td width="100%">${l.l('Наименование')}</td>
		<td>${l.l('Тип')}</td>
	</tr>
	<c:forEach var="item" items="${frd.itemList}">
		<c:url var="editUrl" value="${form.requestURI}">
			<c:param name="method" value="itemGet"/>
			<c:param name="id" value="${item.id}"/>
			<c:param name="returnUrl" value="${form.requestUrl}"/>
		</c:url>
		<c:url var="deleteUrl" value="${form.requestURI}">
			<c:param name="method" value="itemDelete"/>
			<c:param name="id" value="${item.id}"/>
		</c:url>
		<tr class="${item.deleted ? 'deleted' : ''}">
			<td nowrap="nowrap">
				<ui:button type="edit" styleClass="btn-small" onclick="$$.ajax.loadContent('${editUrl}', this)"/>
				<c:if test="${not item.deleted}">
					<ui:button type="del" styleClass="btn-small" onclick="$$.ajax.post('${deleteUrl}', {control: this}).done((r) => {
						if (r.data.error) { alert(r.data.error); } else { $$.ajax.loadContent('${form.requestUrl}', this); }
					})"/>
				</c:if>
			</td>
			<td>${item.id}</td>
			<td>${item.title}</td>
			<td>${frd.typeMap[item.itemTypeId].title}</td>
		</tr>
	</c:forEach>
</table>

<shell:title text="${l.l('Номенклатура')}"/>
