{% extends "tcms_base.html" %}
{% load static %}

{% block subtitle %}Nitrate {% endblock %}

{% block custom_stylesheet %}
{% endblock %}

{% block custom_javascript %}
<script type="text/javascript" src="{% static "js/index.js" %}"></script>
<script type="text/javascript" src="{% static "js/footer_at_the_end.js" %}"></script>
{% endblock %}

{% block contents %}

<div id="content">
	<div class="sprites crumble profile_tab">
		<ul>
			<li><a href="{% url "user-profile" user.username %}">Basic Information</a></li>
			{% if user_profile.user == user %}
			<li class="profile_tab_active"><a href="{% url "user-recent" user.username %}">Recent</a></li>
			{% endif %}
		</ul>
	</div>
	<div class="listinfo_content listinfo_index">
		<div class="leftlistinfo">
			<table cellpadding="0" cellspacing="0" class="home_table">
				<tr>
					<th colspan="4">
						<div class="sprites tableheader">
							<div class="sprites tableheaderleft">Test Runs</div>
							<div class="sprites tableheaderright"></div>
						</div>
					</th>
				</tr>
				{% for test_run in last_15_test_runs %}
				<tr>
					<td class="sprites home_table_bar" width="120" align="center">
						<div class="progress-bar" style="float:none">
							<div class="percent">{{ test_run.case_runs_subtotal.complete_percent|floatformat:1 }}%</div>
							<div class="progress-inner" style="width:{{ test_run.case_runs_subtotal.complete_percent|floatformat:1 }}%;">
								<div class="progress-failed" style="width:{{ test_run.case_runs_subtotal.FAILED_percent|floatformat:1 }}%;">
								</div>
							</div>
						</div>
					</td>
					<td colspan="3">
						<a class="link" href="{% url "run-get" test_run.run_id %}">{{ test_run.summary }}</a>
						<div class="grey" style="margin-top:5px">Start at {{ test_run.start_date }}</div>
					</td>
				</tr>
				{% endfor %}
				<tr>
					<th colspan="4">
						{% if test_runs_count %}
						<div class="sprites tablefooter">
                        <div class="left_float">
                        {{ test_runs_count }} test run(s) related to you need to be run, here {% if test_runs_count == 1 %}is{% else %}are{% endif %} the latest {{ last_15_test_runs|length }}.</div>
							<div class="sprites tablefooterleft"></div>

                            <a href="{% url "runs-all" %}?people={{ user.email|iriencode }}&status=running" class="seeall"> SEE ALL</a>
							<div class="sprites tablefooterright"></div>
						</div>
						{% else %}
						<div class="sprites tablefooter">
                        <div class="left_float">No run belong to you.</div>
                        <div class="sprites tablefooterleft"></div>
						<div class="sprites tablefooterright"></div>
						</div>
						{% endif %}
					</th>
				</tr>
			</table>

		</div>
		<div class="rightlistinfo">
			<table cellpadding="0" cellspacing="0" class="home_table" style="margin-left:10px;">
				<tr>
					<th style="min-width:100px"><div class="sprites tableheader"> <div class="sprites tableheaderleft">Test Plans</div></div></th>
					<th class="sprites tableheader" align="left">Product</th>
					<th class="sprites tableheader" align="left">Type</th>
					<th><div class="sprites tableheader" align="left">Runs<div class="sprites tableheaderright"></div></div></th>
				</tr>
				{% for test_plan in last_15_test_plans %}
                {% if test_plan.is_active %}
				<tr class="{% cycle 'odd' 'even' %}">
					<td height="27"><a class="link" href="{{ test_plan.get_absolute_url }}">{{ test_plan.name }}</a></td>
					<td>{{ test_plan.product }}</td>
					<td>{{ test_plan.type }}</td>
					<td><a href="/runs/?plan={{ test_plan.plan_id }}">{{ test_plan.runs_count }}</a></td>
				</tr>
                {% endif %}
				{% endfor %}
				<tr>
					<th colspan="4">
						{% if test_plans_count %}
						<div class="sprites tablefooter">
                            <div class="left_float">You manage {{ test_plans_count }} test plan(s), {{ test_plans_disable_count }} test plan(s) disabled, here {% if test_plans_count == 1 %}is{% else %}are{% endif %} the latest {{ last_15_test_plans|length }}.</div>
							<div class="sprites tablefooterleft"></div>
                            <a class="seeall" href="{% url "plans-all" %}?author__email__startswith={{ user.email|iriencode }}">SEE ALL</a>
							<div class="sprites tablefooterright"></div>
						</div>
						{% else %}
						<div class="sprites tablefooter">
							<div class="left_float">No plan belong to you</div>
                            <div class="sprites tablefooterleft"></div>
							<div class="sprites tablefooterright"></div><a class="create" href="{% url "plans-new" %}">Create</a>
						</div>
						{% endif %}
					</th>
				</tr>
				</table>
		</div>
		<div class="clear"></div>
	</div>
</div>
{% endblock %}
