{% extends "tcms_base.html" %}
{% load static %}
{% block subtitle %}Advanced Search{% endblock %}

{% block custom_javascript %}
<script type="text/javascript" src="{% static "js/advance_search.js" %}"></script>
<script type="text/javascript" src="{% static "js/testplan_actions.js" %}"></script>
<script type="text/javascript" src="/jsi18n/"></script>
<script type="text/javascript" src="{% static "admin/js/core.js" %}"></script>
<script type="text/javascript" src="{% static "admin/js/calendar.js" %}"></script>
<script type="text/javascript" src="{% static "admin/js/admin/DateTimeShortcuts.js" %}"></script>
{% endblock %}

{% block contents %}
	<div class="sprites crumble">
		<a href="{% url "nitrate-index" %}">Home</a>
		>> Advanced Search
	</div>
	<div class="advancedSearchTip advancedSearch">
		<h3>Use the form below as your advanced search：</h3>
		<ul>
			<li>By selecting 'contains' or 'not contains' to include or exclude the tagged results.</li>
			<li>'Actual Tester' indicates the tester of case in a test run, may differ from 'default tester' of test run.</li>
			<li>Relationship Query :
				<p>Any of the three can be used to search one another：</p>
				<p>e.g. Select product 'RHEL6' in plan form,  and set 'Tom' as test run's manager, then search test plan .The result will be the plans under 'RHEL6' and have runs managed by 'Tom'.</p>
			</li>
		</ul>
	</div>
	<div class="itemSearch advancedSearch">
		<form action="{% url "advanced-search" %}" method="get" id="frmSearch">
		{% if errors %}
			<ul>
				<li>Errors -</li>
				{% for k, v in errors %}
				<li>{{k|title}}: {{v}}</li>
				{% endfor %}
			</ul>
		{% endif %}
		<div class="planCaseRun">
			<div class="containerTabGrey">
				<div class="top">
					<h3>Plan</h3>
				</div>
				<div class="content">
					<div class="listinfo">
						<div class="title"><label>Product&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="pl_product" id="pl_product" multiple="multiple" size="5">
								{% for p in products %}
								<option value="{{ p.pk }}">{{ p.name }}</option>
								{% endfor %}
							</select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Component&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="pl_component" id="pl_component" multiple="multiple" size="5"></select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Version&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="pl_version" id="pl_version" multiple="multiple" size="5"></select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>ID&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="pl_id"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Summary&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="pl_summary"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Plan Type&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="pl_type" multiple="multiple" size="5">
								{% for t in plan_types %}
								<option value="{{ t.pk }}">{{ t.name }}</option>
								{% endfor %}
							</select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Author&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="pl_authors"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Owner&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="pl_owners"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Tag&nbsp;:</label></div>
						<div class="listinfo_input">
							<input type="text" style="width:130px;" name="pl_tags"/>
							<select name="pl_tags_exclude" style="width:116px;">
								<option value="false">Contains</option>
								<option value="true">Not Contains</option>
							</select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Active&nbsp;:</label></div>
						<div class="listinfo_input">
							<ul>
								<li>
									<select name="pl_active">
										<option value="">--</option>
										<option value="yes">Active</option>
										<option value="no">Inactive</option>
									</select>
								</li>
							</ul>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Create Time&nbsp;:</label></div>
						<div class="listinfo_input">
								<input type="text" name="pl_created_since" style="width:130px;" class="vDateField"/>
								<a href="javascript:DateTimeShortcuts.openCalendar(0);" id="calendarlink1"></a>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"></div>
						<div class="listinfo_input">
								<input type="text" name="pl_created_before" style="width:130px;" class="vDateField"/>
								<a href="javascript:DateTimeShortcuts.openCalendar(0);" id="calendarlink1"></a>
						</div>
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
			<div class="containerTabGrey">
				<div class="top">
					<h3>Case</h3>
				</div>
				<div class="content">
					<div class="listinfo">
						<div class="title"><label>Product&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="cs_product" id="cs_product" multiple="multiple" size="5">
								{% for p in products %}
								<option value="{{ p.pk }}">{{ p.name }}</option>
								{% endfor %}
							</select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Component&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="cs_component" id="cs_component" multiple="multiple" size="5"></select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Category&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="cs_category" id="cs_category" multiple="multiple" size="5"></select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>ID&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="cs_id"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Summary&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="cs_summary"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Author&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="cs_authors"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Default Tester&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="cs_tester"/></div>
					</div>
						<div class="listinfo">
						<div class="title"><label>Tag&nbsp;:</label></div>
						<div class="listinfo_input">
							<input type="text" style="width:130px;" name="cs_tags"/>
							<select name="cs_tags_exclude" style="width:116px;">
								<option value="false">Contains</option>
								<option value="true">Not Contains</option>
							</select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Issue Key&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="cs_issues"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Status&nbsp;:</label></div>
						<div class="listinfo_input">
							<ul>
								<li><input type="checkbox" name="cs_status" value="1" /><span>Proposed</span></li>
								<li><input type="checkbox" name="cs_status" value="2" /><span>Comfirmed</span></li>
							</ul>
							<ul>
								<li><input type="checkbox" name="cs_status" value="3" /><span>Disabled</span></li>
								<li><input type="checkbox" name="cs_status" value="4" /><span>Need_update</span></li>
							</ul>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Automated&nbsp;:</label></div>
						<div class="listinfo_input">
							<ul>
								<li>
									<select name="cs_auto">
										<option value="">--</option>
										<option value="yes">Automated</option>
										<option value="no">Manual</option>
									</select>
								</li>
							</ul>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Auto Proposed&nbsp;:</label></div>
						<div class="listinfo_input">
							<ul>
								<li>
									<select name="cs_proposed">
										<option value="">--</option>
										<option value="yes">Auto Proposed</option>
										<option value="no">Non Auto Proposed</option>
									</select>
								</li>
							</ul>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Priority&nbsp;:</label></div>
						<div class="listinfo_input">
							<ul>
								{% for priority in priorities.iterator %}
								<li><input type="checkbox" name="cs_priority" value="{{ priority.pk }}" /><span>{{ priority.value }}</span></li>
								{% endfor %}
							</ul>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Script&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="cs_script"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Create Time&nbsp;:</label></div>
						<div class="listinfo_input">
								<input type="text" name="cs_created_since" style="width:130px;" class="vDateField"/>
								<a href="javascript:DateTimeShortcuts.openCalendar(1);" id="calendarlink1"></a>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"></div>
						<div class="listinfo_input">
								<input type="text" name="cs_created_before" style="width:130px;" class="vDateField"/>
								<a href="javascript:DateTimeShortcuts.openCalendar(1);" id="calendarlink1"></a>
						</div>
					</div>
					<div class="clear"></div>
				</div>
				<div class="clear"></div>
			</div>
			<div class="containerTabGrey">
				<div class="top">
					<h3>Run</h3>
				</div>
				<div class="content">
					<div class="listinfo">
						<div class="title"><label>Product&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="r_product" id="r_product" multiple="multiple" size="5">
								{% for p in products %}
								<option value="{{ p.pk }}">{{ p.name }}</option>
								{% endfor %}
							</select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Version&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="r_version" id="r_version" multiple="multiple" size="5"></select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Build&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="r_build" id="r_build" multiple="multiple" size="5"></select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>ID&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="r_id"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Summary&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="r_summary"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Manager&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="r_manager"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Default Tester&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="r_tester"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Actual Tester&nbsp;:</label></div>
						<div class="listinfo_input"><input type="text" name="r_real_tester"/></div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Tag&nbsp;:</label></div>
						<div class="listinfo_input">
							<input type="text" style="width:130px;" name="r_tags"/>
							<select name="r_tags_exclude" style="width:116px;">
								<option value="false">Contains</option>
								<option value="true">Not Contains</option>
							</select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Status&nbsp;:</label></div>
						<div class="listinfo_input">
							<select name="r_running">
								<option value="">All</option>
								<option value="no">Finished</option>
								<option value="yes">Running</option>
							</select>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"><label>Run Time&nbsp;:</label></div>
						<div class="listinfo_input">
								<input type="text" style="width:130px;" class="vDateField" name="r_created_since" id="id_r_created_since"/>
								<a href="javascript:DateTimeShortcuts.openCalendar(2);" id="calendarlink1"></a>
						</div>
					</div>
					<div class="listinfo">
						<div class="title"></div>
						<div class="listinfo_input">
								<input type="text" style="width:130px;" class="vDateField" name="r_created_before" id="id_r_created_since"/>
								<a href="javascript:DateTimeShortcuts.openCalendar(2);" id="calendarlink1"></a>
						</div>
					</div>
					<div class="clear"></div>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		<div class="button_box">
			<input type="hidden" name="target" value="" id="inpTarget"/>
			<input type="button" value="Search Plan" id="btnSearchPlan">
			<input type="button" value="Search Case" id="btnSearchCase">
			<input type="button" value="Search Run" id="btnSearchRun">
			<input type="reset" value="Reset">
		</div>
		</form>
	</div>
{% endblock %}
