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

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

<h3 class="mb1">${l.l('Статусы складов')}</h3>

<p:check action="/admin/plugin/inventory/storeType:statusUpdate">
	<html:form action="${form.requestURI}" styleId="${formUiid}" styleClass="box mb1">
		<input type="hidden" name="method" value="statusUpdate"/>
		<input type="hidden" name="id" value="0"/>
		<input type="hidden" name="returnUrl" value="${form.requestUrl}"/>
		<table class="data">
			<tr>
				<td class="label">${l.l('Наименование')} *</td>
				<td><input type="text" name="title" class="w100p" required/></td>
			</tr>
			<tr>
				<td class="label">${l.l('Цвет')} <small>(#hex)</small></td>
				<td><input type="text" name="color" placeholder="#ffffff" style="width:100px"/></td>
			</tr>
		</table>
		<div class="mt1"><ui:form-ok-cancel/></div>
	</html:form>
</p:check>

<table id="${uiid}" class="data 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.statusList}">
		<c:url var="deleteUrl" value="${form.requestURI}">
			<c:param name="method" value="statusDelete"/>
			<c:param name="id" value="${item.id}"/>
		</c:url>
		<tr>
			<td nowrap="nowrap">
				<p:check action="/admin/plugin/inventory/storeType:statusUpdate">
					<button type="button" class="btn-white icon btn-small" title="${l.l('Редактировать')}" onclick="
						var f = document.getElementById('${formUiid}');
						f.id.value = '${item.id}';
						f.title.value = '${item.title}';
						f.color.value = '${item.color}';
						f.title.focus();
						return false;"><i class="ti-pencil"></i></button>
				</p:check>
				<p:check action="/admin/plugin/inventory/storeType:statusDelete">
					<ui:button type="del" styleClass="btn-small" onclick="
						if ($$.confirm.del()) $$.ajax.post('${deleteUrl}', {control: this}).done(() => $$.ajax.loadContent('${form.requestUrl}', this)); return false;"/>
				</p:check>
			</td>
			<td>${item.id}</td>
			<td>${item.title}</td>
			<td><span style="background:${item.color};padding:2px 8px;">${item.color}</span></td>
		</tr>
	</c:forEach>
</table>

<shell:title text="${l.l('Статусы складов')}"/>
