{% load i18n %}
{% load static %}
{% load extra_filters %}
{% load attachments_tags %}

<td colspan="13" style="padding:10px;">
	<div class="caserunDetail">
		<div class="caserunInfo">
			<div class="container" style="min-height:190px;">
				<h4 style="padding-bottom:3px;">Comments</h4>
				{% if perms.django_comments.add_comment %}
				<form class="update_form" method="POST">
					<table border="0" cellpadding="0" cellspacing="0" width="100%">
						<textarea name="comment" cols="40" rows="10" maxlength="3000" id="id_comment"></textarea>
						<tr>
							<td style="padding:5px 9px 10px 9px;">
								<input type="hidden" name="type" value="html" />
								<input type="hidden" name="field" value="status" />
								<input type="hidden" name="case_id" value="{{ execution.case_id }}" />
								<input type="hidden" name="assignee" value="{{ execution.assignee_id }}" />
								<input type="hidden" name="tested_by" value="{{ execution.tested_by_id }}" />
								<input type="hidden" name="status_id" value="{{ execution.status_id }}" />
								<input type="hidden" name="value" value="" />
								{% if perms.testruns.change_testexecution %}
									{% for status in execution_status %}
										<i class="submit_button {{ status.icon }} fa-2x" style="color: {{status.color}}" statusId="{{ status.pk }}" title="{{ status.name }}"></i>
									{% endfor %}
								{% endif %}
								<input type="submit" class="submit-post" value="Submit">
							</td>
						</tr>
					</table>
				</form>
				{% endif %}

				<h4 class="borderB">Comments History ({{ comments_count }}):
				{% if comments_count > 0 %}
                                <span>[ <a id="showText" class="js-show-comments" data-param="comment{{ execution.pk }}" href="javascript:void(0);">Hide All</a> ]</span>
				{% endif %}
				</h4>

                                {% if comments_count > 0 %}
				<ul class="comment" id="comment{{ execution.pk }}">
					{% for comment in execution_comments %}
					<li>
						<span>#{{ forloop.counter }}</span>
						<span>{{ comment.user.username }}</span>
						<span>{{ comment.submit_date }}</span>
						<div>
						{{ comment.comment|urlize|linebreaksbr }}
						<br>
						{% if perms.comments.can_moderate and comment.user.pk == request.user.pk %}
						<form action="#" method="post" class="form_comment" style="display:inline;">
							<input type="hidden" name="comment_id" value="{{ comment.pk }}" />
							<input class='commentdelete sprites' value='' type='submit' title="Remove Comment" />
						</form>
						{% endif %}
						</div>
					</li>
					{% endfor %}
				</ul>
                                {% endif %}
			</div>
			<div style="padding: 5px 9px 15px 18px;">
				<h4>{% trans "Test Execution Information" %}</h4>
                                <div><span class="detail_title"><span class="detail_title">{% trans "Run Date" %}:</span>{{ execution.close_date }}</div>
                                <div><span class="detail_title">{% trans "Build" %}:</span>{{ execution.build }} <span class="detail_title marginLeft">{% trans "Text Version" %}:</span>{{ execution.case_text_version }}</div>
			</div>
			<div class="container" style="min-height:50px;">
				{% if execution_logs %}
				<h4 class="borderB">Change Log<span>[ <a href="javascript:void(0);" class="js-show-changelog" data-param="changeLog{{ execution.pk }}">Show All</a> ]</span></h4>
				<ul id="changeLog{{execution.pk}}" style="display:none;">
					{% for log in execution_logs %}
					<li><span>{{ log.history_date }}</span><span>{{ log.history_user }}</span><br />{{ log.history_change_reason }}</li>
					{% endfor %}
				</ul>
				{% else %}
				<h4 class="borderB">Change Log</h4>
                                <ul><li class="grey">{% trans "No log recorded" %}.</li></ul>
				{% endif %}
			</div>
		</div>
		<div class="caseInfo">
			<table cellpadding="0" cellspacing="0" border="0" width="100%">
				<tr>
					<td colspan='3'>
						<div class="container">
							<h4>Text</h4>
							<div class="content">{{ test_case_text|markdown2html }}</div>
						</div>
					</td>
				</tr>
			</table>
			<div class="container">
				<table cellpadding="0" cellspacing="0" border="0" width="98%;" style="margin:0 auto;">
					<tr>
						<td>
                                                    <h4 class="borderB">
                                                        {% trans "Bugs and hyperlinks" %}
                                                        <span>[<a href="javascript:void(0);" class="js-add-testlog" data-params='[{{ execution.case_id }}, {{ execution.pk }}]'>{% trans "Add" %}</a>]</span>
                                                        <span style="float:right">[<a href="javascript:void(0);" title="Report" class="js-file-caserun-bug" data-params='[{{ execution.run_id }}, {{ execution.case_id }}, {{ execution.pk }}]'>{% trans "Report bug" %}</a>]</span>
                                                    </h4>

							<div class="content">
									<ul class="ul-format">
										{% for link in execution.links %}
										<li>
											<a {% if link.is_defect %}class="have_bug"{% endif %} href="{{ link.url }}" target="_blank" title="{{ link.url }}">{{ link.name|escape|default:link.url }}</a>
											<span class="grey" style="float: right">
                                                                                            {{ link.created_on|date:"N d, Y" }} |
											    <a href="javascript:void(0);" class="js-remove-testlog" data-param="{{ link.pk }}">
												    <img title="Remove this log" src="{% static 'images/remove_small.png' %}" />
											    </a>
                                                                                        </span>
										</li>
										{% endfor %}
									</ul>
							 </div>
							</td>
						</tr>
					</table>
			</div>
			<div class="container">
				<table cellpadding="0" cellspacing="0" border="0" width="98%;" style="margin:0 auto;">
					<tr>
						<td>
							<h4 class="borderB">
								Attachments
							</h4>
							<ul class="ul-no-format">
                                                                {% get_attachments_for test_case as attachments_list %}
								{% for attachment in attachments_list %}
								<li>
                                                                    <a href="{{ attachment.attachment_file.url }}">{{ attachment.filename }}</a>
								</li>
								{% empty %}
                                                                <li class="grey">{% trans "No attachment found" %}</li>
								{% endfor %}
							</ul>
							{% if perms.attachments.add_attachment %}
                                                            {% url 'testruns-get' execution.run_id as testrun_url %}
                                                            {% attachment_form execution.case next=testrun_url %}
							{% endif %}
						</td>
						<td style="width:24px;"></td>
						<td>
                                                    <h4 class="borderB">{% trans "Component" %}</h4>
							<ul class="ul-no-format">
								{% for component in test_case.component.all %}
								<li>{{ component.name }}</li>
								{% empty %}
                                                                <li class="grey">{% trans "No component found" %}</li>
								{% endfor %}
							</ul>
						</td>
						<td style="width:24px;"></td>
						<td>
							<h4 class="borderB">Tag:</h4>
							<ul class="ul-no-format">
								{% for tag in test_case.tag.all %}
								<li>{{ tag }}</li>
								{% empty %}
                                                                <li class="grey">{% trans "No tag found" %}</li>
								{% endfor %}
							</ul>
						</td>
					</tr>
				</table>
			</div>

		</div>
		<div class="clear"></div>
	</div>
</td>
