#set ($page_title = 'Task List')
#set ($init_js = '')

	<script src="$link.setRelative('/resources/TaskList.js')" language="JavaScript"></script>
	<div id="menu"> 
		<h2>Menu</h2>
		<ul>
			<li><a href="$link.setAction('/openAddForm')"><img src="$link.setRelative('/resources/skin/default/image/icon/normal16.png')"/>新規タスクを追加</a></li>
		</ul>

		<h2>Search</h2>
		<form id="searchForm" action="$link.setRelative('/search')" method="GET" onmouseover="activateForm(this);">
			<input type="hidden" name="order" value="$taskQuery.order"/>
			<input type="hidden" name="limit" value="$taskPager.limit"/>
			<input type="text" class="text" name="keyword" value="$taskQuery.keyword"/>
			<input type="submit" class="submit" value="検索"/>
			<script type="text/javascript" charset="utf-8">
				<!--
				function toggleQuery(target, id) {
					var elmOption = $(target + 'Option' + id);
					elmOption.selected = !elmOption.selected;
					var cls = elmOption.selected ? 'search-on' : 'search-off';
					Element.classNames(target + 'Item'+id).set(cls)
					$('searchForm').submit();
				}
				-->
			</script>
			<h3 class="accordion-header-close" onclick="toggleAccordion(this, 'searchStatus')" id="searchStatusHeader">状態</h3>
			<ul id="searchStatus" class="searchStatus accordion-close">
#foreach($status in $statusList)
				<li id="searchStatusItem${status.statusId}" class="$utils.decode($taskQuery.hasStatus($status.statusId), 'search-on', 'search-off')"><a class="status${status.statusId}" href="javascript:toggleQuery('searchStatus', $status.statusId);">$status.name</a></li>
#end
			</ul>
			<select multiple="true" name="status" class="hidden">
#foreach($status in $statusList)
				<option id="searchStatusOption${status.statusId}" $utils.decode($taskQuery.hasStatus($status.statusId), 'selected="selected"', '')>${status.statusId}</option>
#end
			</select>
			<h3 class="accordion-header-close" onclick="toggleAccordion(this, 'includeTagList');">このタグをすべて含む</h3>
			<ul class="accordion-close" id="includeTagList">
#foreach($tag in $tagList)
			<li id="includeTagItem${tag.tagId}" class="$utils.decode($taskQuery.hasTag($tag.name), 'search-on', 'search-off')"><a href="javascript:toggleQuery('includeTag', $tag.tagId);">$tag.name</a></li>
#end
			</ul>
			<select multiple="true" name="tag" class="hidden">
#foreach($tag in $tagList)
				<option id="includeTagOption${tag.tagId}" $utils.decode($taskQuery.hasTag($tag.name), 'selected="selected"', '')>$tag.name</option>
#end
			</select>
			<h3 class="accordion-header-close" onclick="toggleAccordion(this, 'excludeTagList');">このタグを含まない</h3>
			<ul class="accordion-close" id="excludeTagList">
#foreach($tag in $tagList)
			<li id="excludeTagItem${tag.tagId}" class="$utils.decode($taskQuery.hasExcludeTag($tag.name), 'search-on', 'search-off')"><a href="javascript:toggleQuery('excludeTag', $tag.tagId);">$tag.name</a></li>
#end
			</ul>
			<select multiple="true" name="excludeTag" class="hidden">
#foreach($tag in $tagList)
				<option id="excludeTagOption${tag.tagId}" $utils.decode($taskQuery.hasExcludeTag($tag.name), 'selected="selected"', '')>$tag.name</option>
#end
			</select>
#set ($hasPriority = $taskQuery.hasPriorityFrom() || $taskQuery.hasPriorityTo())
			<h3 class="$utils.decode($hasPriority, 'accordion-header-open', 'accordion-header-close')" onclick="toggleAccordion(this, 'searchPriority')">優先度</h3>
			<p id="searchPriority" style="$utils.decode($hasPriority, '', 'display:none;')">
				<script type="text/javascript" charset="utf-8">
					<!--
					function searchPriority(elementId, priority) {
						$(elementId).value = priority;
						$(elementId).form.submit();
					}
					-->
				</script>
				<input type="hidden" id="priorityFrom" name="priorityFrom" value="$taskQuery.priorityFrom">
				<input type="hidden" id="priorityTo" name="priorityTo" value="$taskQuery.priorityTo">
				<label for="priorityFrom">from:</label>
				<span id="priorityFromIcon" class="priority${taskQuery.priorityFrom}">
				<div class="horizontal-priority-set" onmouseout="updatePriorityIcon('priorityFromIcon', $('priorityFrom').value);">
					<img class="icon-priority1" onmouseover="updatePriorityIcon('priorityFromIcon', 1)" onclick="searchPriority('priorityFrom', 1)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority2" onmouseover="updatePriorityIcon('priorityFromIcon', 2)" onclick="searchPriority('priorityFrom', 2)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority3" onmouseover="updatePriorityIcon('priorityFromIcon', 3)" onclick="searchPriority('priorityFrom', 3)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority4" onmouseover="updatePriorityIcon('priorityFromIcon', 4)" onclick="searchPriority('priorityFrom', 4)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority5" onmouseover="updatePriorityIcon('priorityFromIcon', 5)" onclick="searchPriority('priorityFrom', 5)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority0" onmouseover="updatePriorityIcon('priorityFromIcon', 0)" onclick="searchPriority('priorityFrom', 0)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
				</div>
				</span>
				<label for="priorityTo">to:</label>
				<span id="priorityToIcon" class="priority${taskQuery.priorityTo}">
				<div class="horizontal-priority-set" onmouseout="updatePriorityIcon('priorityToIcon', $('priorityTo').value)">
					<img class="icon-priority1" onmouseover="updatePriorityIcon('priorityToIcon', 1)" onclick="searchPriority('priorityTo', 1)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority2" onmouseover="updatePriorityIcon('priorityToIcon', 2)" onclick="searchPriority('priorityTo', 2)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority3" onmouseover="updatePriorityIcon('priorityToIcon', 3)" onclick="searchPriority('priorityTo', 3)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority4" onmouseover="updatePriorityIcon('priorityToIcon', 4)" onclick="searchPriority('priorityTo', 4)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority5" onmouseover="updatePriorityIcon('priorityToIcon', 5)" onclick="searchPriority('priorityTo', 5)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority0" onmouseover="updatePriorityIcon('priorityToIcon', 0)" onclick="searchPriority('priorityTo', 0)" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
				</div>
				</span>
			</p>
#set ($hasDeadEndDate = $taskQuery.hasDeadEndDateFrom() || $taskQuery.hasDeadEndDateTo())
			<h3 class="$utils.decode($hasDeadEndDate, 'accordion-header-open', 'accordion-header-close')" onclick="toggleAccordion(this, 'deadEndDate');">〆切</h3>
			<p id="deadEndDate" style="$utils.decode($hasDeadEndDate, '', 'display:none;')">
				<label for="deadEndDateFrom">from:</label> <input type="text" class="text" id="deadEndDateFrom" name="deadEndDateFrom" value="$utils.formatDate($taskQuery.deadEndDateFrom)">
				<label for="deadEndDateTo">to:</label> <input type="text" class="text" id="deadEndDateTo" name="deadEndDateTo" value="$utils.formatDate($taskQuery.deadEndDateTo)">
			</p>
#set ($hasUpdateDate = $taskQuery.hasUpdateDateFrom() || $taskQuery.hasUpdateDateTo())
			<h3 class="$utils.decode($hasUpdateDate, 'accordion-header-open', 'accordion-header-close')" onclick="toggleAccordion(this, 'updateDate');">更新日</h3>
			<p id="updateDate" style="$utils.decode($hasUpdateDate, '', 'display:none;')">
				<label for="updateDateFrom">from:</label> <input type="text" class="text" id="updateDateFrom" name="updateDateFrom" value="$utils.formatDate($taskQuery.updateDateFrom)">
				<label for="updateDateTo">to:</label> <input type="text" class="text" id="updateDateTo" name="updateDateTo" value="$utils.formatDate($taskQuery.updateDateTo)">
			</p>
#set ($hasCreateDate = $taskQuery.hasCreateDateFrom() || $taskQuery.hasCreateDateTo())
			<h3 class="$utils.decode($hasCreateDate, 'accordion-header-open', 'accordion-header-close')" onclick="toggleAccordion(this, 'createDate');">作成日</h3>
			<p id="createDate" style="$utils.decode($hasCreateDate, '', 'display:none;')">
				<label for="createDateFrom">from:</label> <input type="text" class="text" id="createDateFrom" name="createDateFrom" value="$utils.formatDate($taskQuery.createDateFrom)">
				<label for="createDateTo">to:</label> <input type="text" class="text" id="createDateTo" name="createDateTo" value="$utils.formatDate($taskQuery.createDateTo)">
			</p>
			<input type="submit" class="submit" value="検索"/>
		</form>
	</div>
    <!-- menu -->
	<div id="main">
#set ($action = $link.setRelative('/search'))
#prepareSearchTaskActionPlain($action $taskQuery)
#pagerMarkup($action $taskPager)
(見積合計: $taskPager.manHour)
		<table class="list" width="99%">
		<tr> 
#set ($action = $link.setRelative('/search'))
#if(!$taskQuery.hasOrder(1))
#prepareSearchTaskActionForOrder($action $taskQuery $taskPager 1)
#else
#prepareSearchTaskActionForOrder($action $taskQuery $taskPager 2)
#end
			<th nowrap="nowrap"><a href="$action">状態#sortImage($taskQuery 1 2)</a></th>
#set ($action = $link.setRelative('/search'))
#if(!$taskQuery.hasOrder(12))
#prepareSearchTaskActionForOrder($action $taskQuery $taskPager 12)
#else
#prepareSearchTaskActionForOrder($action $taskQuery $taskPager 11)
#end
			<th nowrap="nowrap"><a href="$action"><img src="$link.setRelative('resources/skin/default/image/icon/star-off.gif')" alt="優先度"/>#sortImage($taskQuery 12 11)</a></th>
			<th nowrap="nowrap">タスク</th>
#set ($action = $link.setRelative('/search'))
#if(!$taskQuery.hasOrder(9))
#prepareSearchTaskActionForOrder($action $taskQuery $taskPager 9)
#else
#prepareSearchTaskActionForOrder($action $taskQuery $taskPager 10)
#end
			<th nowrap="nowrap"><a href="$action">〆切#sortImage($taskQuery 9 10)</a></th>
#set ($action = $link.setRelative('/search'))
#if(!$taskQuery.hasOrder(8))
#prepareSearchTaskActionForOrder($action $taskQuery $taskPager 8)
#else
#prepareSearchTaskActionForOrder($action $taskQuery $taskPager 7)
#end
			<th nowrap="nowrap"><a href="$action">更新日#sortImage($taskQuery 7 8)</a></th>
		</tr>
#foreach($task in $taskList)
		<tr id="task-${task.taskId}"> 
			<td class="statusIcon">
				<img id="statusIcon-${task.taskId}" class="status${task.statusId}-icon" src='$link.setRelative("/resources/skin/default/image/spacer.gif")' alt="$task.statusBean.name"/>
				<ul>
	#foreach($status in $statusList)
					<li><a href="javascript:updateStatus(${task.taskId},${status.statusId})"><img class="status${status.statusId}" src="$link.setRelative('resources/skin/default/image/spacer.gif')" alt="$status.name" /></a></li>
	#end
				</ul>
			</td>
			<td id="taskPriority-$task.taskId" class="priority${task.priority}">
				<input type="hidden" id="taskOriginalPriority-$task.taskId" value="$task.priority">
				<div class="vertical-priority-set" onmouseout="updatePriorityIcon('taskPriority-$task.taskId', $('taskOriginalPriority-$task.taskId').value)">
					<img class="icon-priority1" onmouseover="updatePriorityIcon('taskPriority-$task.taskId', 1)"  onclick="updatePriority($task.taskId, 1);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority2" onmouseover="updatePriorityIcon('taskPriority-$task.taskId', 2)"  onclick="updatePriority($task.taskId, 2);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority3" onmouseover="updatePriorityIcon('taskPriority-$task.taskId', 3)"  onclick="updatePriority($task.taskId, 3);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority4" onmouseover="updatePriorityIcon('taskPriority-$task.taskId', 4)"  onclick="updatePriority($task.taskId, 4);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority5" onmouseover="updatePriorityIcon('taskPriority-$task.taskId', 5)"  onclick="updatePriority($task.taskId, 5);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
					<img class="icon-priority0" onmouseover="updatePriorityIcon('taskPriority-$task.taskId', 0)"  onclick="updatePriority($task.taskId, 0);" src="$link.setRelative('/resources/skin/default/image/spacer.gif')"/>
				</div>
			</td>
			<td class="text">
#if($task.tagList.length() > 0)
				<ul class="tagList">
#foreach($tag in $task.tagAsList)
					<li class="$tagMap.get($tag).tagTypeBean.styleClass">$tag</li>
#end
				</ul>
#end

				$utils.formatHtmlSimple($task.contents)
				<ul class="actionList">
					<li><a class="viewAction" href='$link.setRelative("/$task.taskId/")'>閲覧</a></li>
					<li><a class="deleteAction" href="javascript:deleteTask($task.taskId, 'task-${task.taskId}')">削除</a></li>
				</ul>
				<p class="note">ID: $task.taskId, 見積: $task.estimatedManHour, 作成日: $utils.formatDate($task.createDate)</p>
			</td>
			<td id="deadEndDate-${task.taskId}">$utils.formatDate($task.deadEndDate)</td>
			<td id="updateDate-${task.taskId}">$utils.formatTimestamp($task.updateDate)</td>
		</tr>
#end
		</table>
#set ($action = $link.setRelative('/search'))
#prepareSearchTaskActionPlain($action $taskQuery)
#pagerMarkup($action $taskPager)
	</div>
	<!-- main -->
