<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jspf/include/taglibs.jsp"%>
<c:set var="map" value="${dataMap['moduleTitles']}"></c:set>
<div class="report">
	<table cellspacing='1' class="table800">
		<thead>
		  <tr>
		  	<td>Название</td>
		  	<td>Тип</td>
		  	<td>Адреса</td>
		  	<td>Статус</td>
		  	<td>Правка</td>
		  	<td>Удаление</td>		  	
		  </tr>
		 </thead>
		 <tbody>
		<c:forEach var="item" items="${dataMap['userDispatches']}">
			<tr>
				<td>${item.title }</td>
				<c:set var="mid" value="${item['dispatchReference'].moduleID}"></c:set>
				<c:set var="t" value="${map[mid]}::${item['dispatchReference'].title }"></c:set>
				<c:if test="${empty mid or mid eq 0}">
					<c:set var="t" value="${item['dispatchReference'].title }"></c:set>
				</c:if>
				<td>${t}</td>
				<td>${item.mailList}</td>
				<td>
					<c:set var="status" value="неактивна" ></c:set>
					<c:if test="${item.status == 1}">
						<c:set var="status" value="активна" ></c:set>
					</c:if>
					${status}				
				</td>
				<td>
					<form method='get' action=''>
					<input type="hidden" name="action" value="Subscription"/>
					<input type="hidden" name="command" value="edit"/>
					<input type="hidden" name="id" value="${item.ID}"/>
					<input type="hidden" name="type" value="${item.dispatchType}"/>
					<input type="submit" value="Править"/>
					</form>	
				</td>
				<td>
					<form method='get' action='' onsubmit="return confirm('Удалить рассылку?')">
					<input type="hidden" name="action" value="Subscription"/>
					<input type="submit" value="Удалить"/>
					<input type="hidden" name="command" value="delete"/>
					<input type="hidden" name="id" value="${item.ID }"/>
					</form>
				</td>				
			</tr>
		</c:forEach>		
		</tbody>
	</table>
</div>

<br/>
<form method='get' action=''>
<input type="hidden" name="action" value="Subscription"/>
<input type="hidden" name="command" value="new"/>
<input type="hidden" name="id" value="new"/>
	<table border='0' class="filter">
	  <tr>
		<th>Рассылка:</th>
		<td>
			<select name="type">
		  		<c:forEach var="item" items="${dataMap['references']}">
		  			<c:set var="mid" value="${item.moduleID}"></c:set>
					<c:set var="t" value="${map[mid]}::${item.title }"></c:set>
					<c:if test="${ empty mid or mid eq 0}">
						<c:set var="t" value="${item.title }"></c:set>
					</c:if>
		  			<option value="${item.ID}" >  ${t} </option>
		  		</c:forEach>
			</select>
		</td>
		<td>
			<input type="submit" value="Добавить">
		</td>
	  </tr>
	</table>
</form>
