{% load i18n %}
{% load comments %}
{% load report_tags %}
{% load static %}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>{{ testrun.summary }}</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<meta http-equiv="Content-Language" content="utf-8" />
	<link rel="stylesheet" type="text/css" href="{% static 'style/print.css' %}" media="all" />
</head>
<body>
	<div class="report_title">
            {% trans "Test Execution Report" %}
	<div class="report_sub_title"><a href='{% url "testruns-get" test_run.pk %}'>[{{ test_run.pk }}] {{ test_run.summary }}</a></div></div>
	<div class="report_content">
	<div id="content">
		<div class="listinfo_content" style="float:left; width:95%">
			<div class="leftlistinfo">
				<div class="listinfo">
                                    <span class="title">{% trans "Test Plan" %}:</span>{{ test_run.plan.pk }}:{{ test_run.plan.name }}
				</div>
				<div class="listinfo">
                                    <span class="title">{% trans "Product Version" %}:</span>{{ test_run.product_version }}
				</div>
				<div class="listinfo">
                                    <span class="title">{% trans "Manager" %}:</span>{{ test_run.manager.username }}
				</div>
			</div>
			<div class="rightlistinfo">
				<div class="listinfo">
                                    <span class="title">{% trans "Product" %}:</span>{{ test_run.build.product }}
				</div>
				<div class="listinfo">
                                    <span class="title">{% trans "Build" %}:</span>{{ test_run.build }}
				</div>
				<div class="listinfo">
                                    <span class="title">{% trans "Default Tester" %}:</span>{{ test_run.default_tester }}
				</div>
				<div class="listinfo">
                                    <span class="title">{% trans "Started at" %}:</span>{{ test_run.start_date }}
				</div>
				<div class="listinfo">
                                    <span class="title">{% trans "Finished at" %}:</span>{{ test_run.stop_date }}
				</div>
			</div>
			<div class="listinfo">
                            <span class="title">{% trans "Note" %}:</span>{{ test_run.notes|urlize|linebreaksbr }}
			</div>
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
		<div class="table_noborder">
                    {% trans "Manual Cases" %}<span class="red">{{ mode_stats.manual|percentage:executions_count }}({{ mode_stats.manual }}/{{ executions_count }})</span>
                    {% trans "Automated Cases" %}<span class="red">{{ mode_stats.automated|percentage:executions_count }}({{ mode_stats.automated }}/{{ executions_count }})</span>
		</div>

		{% if executions %}
		<table class="list border-1" cellpadding="0" cellspacing="0">
			<tr>
                            <th class="widthID">{% trans "Case-Run ID" %}</th>
                            <th class="widthID">{% trans "Case ID" %}</th>
                            <th>{% trans "Summary" %}</th>
                            <th width="100">{% trans "Automated" %}</th>
                            <th width="100">{% trans "Tested by" %}</th>
                            <th width="150">{% trans "Category" %}</th>
                            <th width="100">{% trans "Status" %}</th>
                            <th width="160" height="25px">{% trans "Closed at" %}</th>
			</tr>
			{% for execution in executions %}
			<tr>
				<td>{{ execution.pk }}</td>
				<td>{{ execution.case_id }}</td>
				<td>{{ execution.case.summary }}</td>
				<td>{{ execution.case.is_automated }}</td>
				<td>{{ execution.tested_by.username }}</td>
				<td>{{ execution.case.category.name }}</td>
				<td><span class="highlight">{{ execution.status.name|upper }}</span></td>
				<td>{{ execution.close_date }}</td>
			</tr>
			<tr>
				<td align="left" valign="top" colspan="8" class='hide'>
					{% for bug in execution.get_bugs %}
                                            {% if forloop.first %}
                                                <h4>{% trans "Bugs" %}:</h4>
                                            {% endif %}
					<a href="{{ bug.url }}">{{ bug.url }}</a><br/>
					{% endfor %}

					{% if execution.user_comments %}
					<h4>{% trans "Comments" %}:</h4>
					<span class="notes" >
						<ul style="margin-left:10px;" class='comment'>
							{% for comment in execution.user_comments %}
							<li><b>{{ comment.user_name }}</b><span class='grey' style='margin-left:5px'>[{{ comment.submit_date }}]</span>	<br />{{ comment.comment|urlize|linebreaksbr }}</li>
							{% endfor %}
						</ul>
					</span> 
					{% endif %}

					</td>
			</tr>
			{% endfor %}
		</table>
		{% endif %}

		<h3>Total: {{ executions_count }}</h3>
		<h3>Pending test cases: {{ summary_stats.idle }}</h3>
		<h3>Test run completed: {{ summary_stats.complete|percentage:executions_count }}</h3>

                <hr/>
                <table class="list border-1" cellpadding="0" cellspacing="0">
                    <tr>
                        <th>{% trans "Bug List" %}</th>
                    </tr>
                    {% for execution in executions %}
                        {% for bug in execution.get_bugs %}
                            <tr>
                                <td><a href="{{ bug.url }}" target="_blank">{{ bug.url }}</a></td>
                            </tr>
                        {% endfor %}
                    {% endfor %}
                </table>
	</div>
	</div>
</body>
</html>
