<div id="task" class="tab-pane fade in">

	<!-- modal -->
	<div class="modal fade" id="modalTaskHow" tabindex="-1" role="dialog" aria-labelledby="modalTaskHowTitle">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="modalTaskHowTitle">Стратегия съёмки</h4>
				</div>
				<div class="modal-body"></div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
				</div>
			</div>
		</div>
	</div>
	
	<div class="modal fade" id="modalTaskRemove" tabindex="-1" role="dialog" aria-labelledby="modalTaskRemoveTitle">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<form>
					<input type="hidden" name="id">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="modalTaskRemoveTitle">Подтверждение удаления</h4>
					</div>
					<div class="modal-body">Удалить объект &laquo;<span class="obj"></span>&raquo;</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
						<button type="submit" class="btn btn-danger">Удалить</button>
					</div>
				</form>
			</div>
		</div>
	</div>

	<div class="modal fade" id="modalTaskEdit" tabindex="-1" role="dialog" aria-labelledby="modalTaskEditTitle">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<form>
					<input name="id" type="hidden">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						<h4 class="modal-title" id="modalTaskEditTitle">@</h4>
					</div>
					<div class="modal-body">
						<div class="form-group has-feedback">
							<label>Объект</label>
							<input type="text" class="form-control" name="obj">
							<span class="glyphicon form-control-feedback hidden"></span>
							<span class="help-block hidden">Объект не найден, введите координаты</span>
						</div>
						<div class="row">
							<div class="form-group col-lg-6">
								<label>RA</label>
								<input type="text" class="form-control" name="ra">
							</div>
							<div class="form-group col-lg-6">
								<label>DEC</label>
								<input type="text" class="form-control" name="dec">
							</div>
						</div>
					
						<div class="form-group">
							<label>Как снимать</label>
							<script id="templateTaskEditHow" type="text/x-jquery-tmpl">
								<option value="${id}">${name}</option>
							</script>
							<select class="form-control" id="taskHowSelect" name="how" multiple=true required>
							</select>
						</div>
						
						<div class="form-group row">
							<div class="col-lg-3">
								<label>Луна</label>
							</div>
							<div class="col-lg-9">
								<label>
									<input type="radio" name="moon" value="any" id="taskEditMoonAny"> Не важно
								</label>
								<label>
									<input type="radio" name="moon" value="no" id="taskEditMoonNo"> Без Луны
								</label>
								<label>
									<input type="radio" name="moon" value="yes" id="taskEditMoonYes"> С Луной
								</label>
							</div>
						</div>
						
						<div id="taskEditMoon" class="form-border">

							<div class="form-group">
								<label>Луна не ближе, °</label>
								<input type="number" class="form-control" name="moonDegree">
							</div>
							<div class="row">
								<div class="form-group col-lg-6">
									<label>В фазе от, %</label>
									<input min="0" max="99" type="number" class="form-control" name="moonFrom">
								</div>
								<div class="form-group col-lg-6">
									<label>В фазе до, %</label>
									<input min="1" max="100" type="number" class="form-control" name="moonTill">
								</div>
							</div>
						
						</div>
						
						<div class="form-group row" style="padding-top: 5px">
							<div class="col-lg-3">
								<label>Когда снимать</label>
							</div>
							<div class="col-lg-9">
								<label>
									<input type="radio" name="when" value="culm" id="taskEditWhenCulmRadio"> Близ кульминации
								</label>
								<label>
									<input type="radio" name="when" value="above" id="taskEditWhenAboveRadio"> В любое время
								</label>
							</div>
						</div>
						
						<div id="taskEditWhenCulm" class="form-border">

							<div class="form-group">
								<label>Время близ кульминации, ч</label>
								<input min="1" max="14" type="number" class="form-control" name="whenCulmHour">
							</div>
							
							<div class="form-group row">
								<div class="col-lg-3">
									<label>Перекладка</label>
								</div>
								<div class="col-lg-9">
									<label>
										<input type="radio" name="whenCulmDirection" value="south" id="taskEditWhenCulmSouth"> Юг (с перекладкой)
									</label>
									<label>
										<input type="radio" name="whenCulmDirection" value="east" id="taskEditWhenCulmEast"> Восток (без перекладки)
									</label>
									<label>
										<input type="radio" name="whenCulmDirection" value="west" id="taskEditWhenCulmWest"> Запад (без перекладки)
									</label>
								</div>
							</div>
						
						</div>
															
						<div id="taskEditWhenAbove" class="form-border">
							<div class="form-group">
								<label>Высота объекта не ниже, °</label>
								<input min="0" max="89" type="number" class="form-control" name="whenDegree">
							</div>
						</div>
															
						<div class="form-group">
							<label>Нужно отснять времени, ч</label>
							<input type="number" class="form-control" name="hours">
						</div>
						
						<div class="form-group">
							<label>Комментарий</label>
							<textarea class="form-control" rows="3" name="note"></textarea>
						</div>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">Закрыть</button>
						<button type="submit" class="btn btn-success">@</button>
					</div>
				<form>
			</div>
		</div>
	</div>
	<!-- // modal -->
	
	<!-- template -->
	<script id="templateTaskHow" type="text/x-jquery-tmpl">
		<div>Название: ${name}</div>
		{{if filters}}
			<table class="table table-striped">
				<thead>
					<tr>
						<th>Фильтр</th>
						<th>Выдержка, мин.</th>
						<th>Bin</th>
						<th>Количество</th>
					</tr>
				</thead>
				<tbody>
					{{each filters}}
						<tr>
							<td>${$value.name}</td>
							<td>${$value.exposure}</td>
							<td>${$value.bin}</td>
							<td>${$value.count}</td>
						</tr>
					{{/each}}
				</tbody>
			</table>
		{{/if}}
	</script>

	<script id="templateTaskItem" type="text/x-jquery-tmpl">
		<tr data-id="${id}">
			<td class="priority-${$item.priority.class[priority]}">${$item.priority.name[priority]}</td>
			<td class="obj">
				{{if $item.data.obj}}
					${obj}<br>
				{{/if}}
				{{if $item.data.ra}}
					${ra} / ${dec}
				{{/if}}
			</td>
			<td>
				{{if $item.data.moon == 'yes'}}
					при Луне (не ближе ${moonDegree}°!)<br>
					В фазе ${moonFrom}..${moonTill}%
				{{else $item.data.moon == 'no'}}
					без Луны
				{{else}}
					не важно
				{{/if}}
			</td>
			<td>
				{{if $item.data.whenCulmDirection == ''}}
					объект выше ${whenDegree}°
				{{else}}
					${whenCulmHour}ч близ кульминации (${$item.direction[whenCulmDirection]})
				{{/if}}
			</td>
			<td>
				{{each how}}
					<a href="#" data-id="${$value.id}" class="task-how-info">${$value.name}</a><br>
				{{/each}}
			<td>
				{{if $item.data.done > 0}}${done.toFixed(1)} / {{/if}}${hours} ч
				{{if $item.data.done > 0}}<br>(${(done/hours * 100).toFixed(0)}% готово){{/if}}
			</td>
			</td>
			<td>
				<a href="#" class="btn btn-sm btn-info glyphicon glyphicon-edit task-edit-button"></a>
				<a href="#" class="btn btn-sm btn-warning glyphicon glyphicon-remove task-remove-button"></a>
			</td>
		</tr>
	</script>
	<!-- // template -->
	

	<h3>Задания <a href="#" class="btn btn-sm btn-info glyphicon glyphicon-plus task-add-button"></a></h3>
	<table class="table table-striped">
		<thead>
			<tr>
				<th>Приоритет</th>
				<th>Объект / координаты</th>
				<th>Луна</th>
				<th>Когда снимать</th>
				<th>Как снимать</th>
				<th>Сколько снимать</th>
				<th></th>
			</tr>
		</thead>
		<tbody class="task-list">
		</tbody>
	</table>
</div>

