<form class="js-cases-actions" action="{% url "cases-all" %}" method="get">
	<input type="hidden" name="type" value="{% if show_confirmed_cases %}case{% else %}review_case{% endif %}" />
	<input type="hidden" name="case_sort_by" value="{{ REQUEST_CONTENTS.case_sort_by }}" />
	<input type="hidden" name="plan" value="{{ REQUEST_CONTENTS.from_plan }}" />
	<input type="hidden" name="from_plan" value="{{ REQUEST_CONTENTS.from_plan }}" />
	{# todo: seems this hidden value is still being used somewhere. Leave it here for further check. #}
	<input type="hidden" name="template_type" value="{{ REQUEST_CONTENTS.template_type }}" />
	<div class="tab_navigation actions">
		<div class='toolbar'>
			<ul>
				<li>
					{% if perms.testcases.add_testcase %}
					<span id="js-case-menu" class='sprites toolbar_case icon_plan' data-params='["{% url "cases-new" %}", {{ test_plan.plan_id }}]'>Case</span>
					{% else %}
					<span class='sprites toolbar_case icon_plan'>Case</span>
					{% endif %}
					<ul>
						{% if perms.testcases.add_testcase %}
						<li>
							<input class="add_new icon_plan js-new-case" type="button" value="Write new case"
								data-params='["{% url "cases-new" %}", {{ test_plan.plan_id }}]'/>
						</li>
						<li>
							<input type="button" class="import icon_plan js-import-cases" value="Import cases from XML" />
						</li>
						<li>
							<input type="button" class="search icon_plan js-add-case-to-plan" value="Add cases from other plans"
								data-param="{% url "plan-search-cases-for-link" test_plan.plan_id %}" />
						</li>
						{% else %}
						<li><input type="button" class="add_new icon_plan" disabled value="Write new case" /></li>
						<li><input type="button" class="import icon_plan" disabled value="Import cases from XML" /></li>
						<li><input type="button" class="search icon_plan" disabled value="Add cases from other plans" /></li>
						{% endif %}
						<li>
							<input type="button" class="export icon_plan js-export-cases" value="Export"
								title="Export selected cases into XML file" data-param="{% url "cases-export" %}" />
						</li>
						<li>
							<input type="button" class="print_view icon_plan js-print-cases" value="Print"
								title="print view of selected cases" data-param="{% url "cases-printable" %}" />
						</li>
						{% if perms.testcases.add_testcase %}
						<li>
							<input type="button" class="clone icon_plan js-clone-cases" value="Clone"
								title="Clone selected cases to another test plan" data-param="{% url "cases-clone" %}" />
						</li>
						{% else %}
						<li>
							<input type="button" class="clone icon_plan" value="Clone"
								title="Clone selected cases to another test plan" disabled />
						</li>
						{% endif %}
						{% if perms.testcases.delete_testcaseplan %}
						<li>
							<input type="button" class="delete icon_plan js-remove-cases" value="Remove"
								title="Remove selected cases from this plan" />
						</li>
						{% else %}
						<li>
							<input type="button" class="delete icon_plan" value="Remove"
								title="Remove selected cases from this plan" disabled />
						</li>
						{% endif %}
						{% if perms.testcases.change_testcase %}
						<li>
							<input type="button" class="sort_list icon_plan" value="Set Sort Number"
								title="Set sort number of selected cases from this plan" />
						</li>
						{% else %}
						<li>
							<input type="button" class="sort_list icon_plan" value="Set Sort Number"
								title="Set sort number of selected cases from this plan" disabled />
						</li>
						{% endif %}
					</ul>
				</li>

				{% if show_confirmed_cases %}
				<li>
					<span class='sprites toolbar_run {% if not perms.testruns.add_testrun %}toolbar_run_disabled{% endif %} icon_plan'>Run</span>
					<ul>
						{% if perms.testruns.add_testrun %}
						<li>
							<input type="button" class="new_run icon_plan js-new-run" value="Write a new run"
								data-param="{% url "run-new" %}" />
						</li>
						<li>
							<input type="button" class="search icon_plan js-add-case-to-run" value="Add cases to run"
								data-param="{% url "plan-choose-run" test_plan.plan_id %}" />
						</li>
						{% else %}
						<li>
							<input type="button" class="new_run icon_plan" value="Write a new run" disabled />
						</li>
						<li><input type="button" class="search icon_plan" value="Add cases to run" disabled /></li>
						{% endif %}
					</ul>
				</li>
				{% endif %}

				<li>
					<span class='sprites toolbar_tag {% if not perms.testcases.add_testcasetag %}toolbar_tag_disabled{% endif %} icon_plan'>Tag</span>
					<ul>
						{% if perms.testcases.add_testcasetag %}
						<li><input type="button" value="Add Tag" class="tag_add sprites icon_plan" /></li>
						{% else %}
						<li><input type="button" value="Add Tag" class="tag_add_disabled sprites icon_plan" disabled /></li>
						{% endif %}
						{% if perms.testcases.delete_testcasetag %}
						<li><input type="button" value="Remove Tag" class="tag_delete sprites icon_plan" /> </li>
						{% else %}
						<li><input type="button" value="Remove Tag" class="tag_delete_disabled sprites icon_plan" disabled /></li>
						{% endif %}
					</ul>
				</li>

				{% if perms.testcases.change_testcase %}
				<li>
					<input type="button" value="Automated" title="change automated" class="btn_automated automated sprites icon_plan" />
				</li>
				{% if show_confirmed_cases %}
				<li>
					<input type="button" value="Default Tester" title="change default tester"
						class="btn_default_tester assignee sprites icon_plan" />
				</li>
				{% else %}
				<li>
					<input type="button" value="Reviewer" title="change reviewer" class="btn_reviewer assignee sprites icon_plan" />
				</li>
				{% endif %}
				<li>
					<input type="button" value="Component" class="btn_component sprites component icon_plan" />
				</li>
				<li><span class='sprites toolbar_status icon_plan'>Status</span>
					<ul>
						{% for cs in case_status %}
						<li>
							<input type='button' value='Set {{ cs }}' class='btn_case_status {{ cs|lower }} icon_plan js-status-item'
								data-param="{{ cs.pk }}" />
						</li>
						{% endfor %}
					</ul>
				</li>
				<li>
					<input type="button" value="Category" class="btn_category sprites category icon_plan" />
				</li>
				<li>
					<span class='sprites toolbar_priority icon_plan'>Priority</span>
					<ul>
						{% for priority in priorities %}
						<li>
							<input type='button' value='Set {{ priority }}' class='btn_case_priority {{ priority|lower }} icon_plan js-priority-item'
								data-param="{{ priority.pk }}" />
						</li>
						{% endfor %}
					</ul>
				</li>
				{% else %}
				<li>
					<input type="button" value="Automated" title="change automated"
						class="btn_automated automated_disabled sprites icon_plan" disabled />
				</li>
				{% if show_confirmed_cases %}
				<li>
					<input type="button" value="Default tester" title="change default tester"
						class="btn_default_tester assigneedisable sprites icon_plan" disabled />
				</li>
				{% else %}
				<li>
					<input type="button" value="Reviewer" title="change reviewer"
						class="btn_reviewer assigneedisable sprites icon_plan" disabled />
				</li>
				{% endif %}
				<li>
					<input id="id_batch_component" type="button" value="Component"
						class="btn_component sprites component_disabled icon_plan" disabled />
					</li>
				{% endif %}
			</ul>
			<span class="reorder_case">
				<a class="btn_filter filtercase" title="Click to toggle filter options">Toggle filter options</a>
				{% if perms.testcases.change_testcase %}
				<a class="btn_sort sortlink" title="Click me,then Drag and drop the rows to adjust the order,and click 'Done Sorting' link to submit your changes">Re-order cases</a>
				{% endif %}
			</span>
		</div>
		<div class="mixbar fixed">
			<div class="tit" style="width: 50px; float: left; height: 100%; margin: 0px; text-align: center;">Tags:</div>
			<div style="margin-left: 50px; line-height:22px;" class="taglist">
				{% for tag in case_own_tags %}
				<a href="javascript:void(0)">{{ tag.tag_name }}</a>&nbsp;&nbsp;<span class="grey">-</span>&nbsp;&nbsp;
				{% empty %}
				<span class="grey">No tags in cases</span>
				{% endfor %}
			</div>
		</div>
	</div>

	<div class="list_filter" {% if REQUEST_CONTENTS.a != 'search' %}style="display:none;"{% endif %}>
		{% include "case/form/filter.html" %}
		<div class="submit-row bottom">
			<span class="tit"><span class="js-number-of-loaded-cases">{{ total_cases_count }}</span> Cases</span>
			<input type="submit" value="Filter cases" />
		</div>
	</div>
</form>