{% extends "base.html" %}
{% import "macros.html" as macros with context %}

{% block head %}
{{ super() }}
<meta name="srp_request_id" content="{{ srp_request.id }}">
{% endblock head %}


{% block body %}
<div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="detailsModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <form class="modal-content" method="post">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden"true">&times;</button>
        {# TRANS: The header for a modal window that is used to change the supporting details of a request (the details are things like what the fleet was doing, a link to an AAR, or something like that). #} 
        <h3 class="modal-title" id="detailsModalLabel">{% trans %}Update Details{% endtrans %}</h3>
      </div>
      <div class="modal-body">
        {{ details_form.csrf_token() }}
        {{ details_form.id_(value='details') }}
        {{ macros.render_input(details_form.details) }}
      </div>
      <div class="modal-footer">
        {# TRANS: A button that when pushed will stop the process of updating the supporting details for a request. #}
        <button type="button" class="btn btn-default" data-dismiss="modal">{% trans %}Cancel{% endtrans %}</button>
        {# TRANS: A button that when pushed, will save the changes made to the supporting details for a request. #}
        <button type="submit" class="btn btn-primary">{% trans %}Save{% endtrans %}</button>
      </div>
    </form>
  </div>
</div>
{{ super() }}
{% endblock body %}

{% block content %}
<div class="row">
  <div class="col-sm-offset-1 col-sm-10 col-md-offset-0 col-md-6 col-lg-offset-1 col-lg-5">
    {% block left_col %}
    <dl class="dl-horizontal">
      {% block info %}
      <dt>{% trans %}External Lossmail{% endtrans %}</dt>
      <dd><a href="{{ srp_request.killmail_url }}" target="_blank">{{ srp_request.id }}</a></dd>
      {# TRANS: The date and time that the loss this request concerns occured. #}
      <dt>{% trans %}Time of Loss{% endtrans %}</dt>
      <dd>{{ srp_request.kill_timestamp|datetimeformat }}</dd>
      <dt>{% trans %}Division{% endtrans %}</dt>
      <dd>
        <span id="request-division">{{ srp_request.transformed.division }}</span> &bull;
        {# TRANS: A button that when clicked begins the process of transferring a request from one division to another. #}
        <a href="{{ url_for('requests.request_change_division', request_id=srp_request.id) }}">{% trans %}Change Division{% endtrans %}</a>
      </dd>
      <dt>{% trans %}Details{% endtrans %}</dt>
      <dd>
        <div class="panel panel-default">
          <p class="panel-body" id="request-details">{{ srp_request.details|urlize(30) }}</p>
        </div>
        {% if not srp_request.finalized and srp_request.submitter == current_user %}
        {# TRANS: A button that when clicked begins the process of updating the supporting details of a request. #}
        <button class="btn btn-default btn-sm" type="button" data-toggle="modal" data-target="#detailsModal">{% trans %}Update Details{% endtrans %}</button>
        {% endif %}
      </dd>
      <dt>{% trans %}Pilot{% endtrans %}</dt>
      <dd id="pilot">
        {{ srp_request.transformed.pilot }}
      </dd>
      {# TRANS: The corporation a pilot was in when the loss occured. #}
      <dt>{% trans %}Corporation{% endtrans %}</dt>
      <dd id="corporation">{{ srp_request.transformed.corporation }}</dd>
      {% if srp_request.alliance is not none %}
      {# TRANS: The alliance a pilot was in when the loss occured. #}
      <dt>{% trans %}Alliance{% endtrans %}</dt>
      <dd id="alliance">{{ srp_request.transformed.alliance|default(' ') }}
      {% endif %}
      {# TRANS: The solar system, constellation and region a loss occured in. #}
      <dt>{% trans %}Location{% endtrans %}</dt>
      <dd>
        <span id="region">{{ srp_request.transformed.region }}</span> /
        <span id="constellation">{{ srp_request.transformed.constellation }}</span> /
        <span id="system">{{ srp_request.transformed.system }}</span>
      </dd>
      <dt>{% trans %}Ship{% endtrans %}</dt>
      <dd>{{ srp_request.transformed.ship_type }}</dd>
      {# TRANS: The status a request is in. Possiblities include Unevaluated, Approved, Rejected, Paid and Incomplete. #}
      <dt>{% trans %}Status{% endtrans %}</dt>
      <dd><span id="request-status" class="label label-{{ macros.status_color(srp_request.status) }}">{{ srp_request.transformed.status }}</span></dd>
      {# TRANS: The payout an evaluated request has been. This number includes all modifiers (bonuses and penalties). #}
      <dt>{% trans %}Payout{% endtrans %}</dt>
      <dd>
      {# TRANS: The base payout assigned to a request as part of the evaluation process. This is without any modifiers (bonuses or penalties). This text is shown as a tooltip when the mouse is moved over the total payout number. #}
      <span id="request-payout" data-toggle="tooltip" title="{% trans base_payout=(srp_request.base_payout|currencyfmt) %}Base Payout: {{ base_payout }}{% endtrans %}">
          {{ srp_request.payout|currencyfmt }}
        </span>
      </dd>
      {% endblock info %}
    </dl>
    {% if current_user.has_permission((PermissionType.review, PermissionType.pay), srp_request) or current_user == srp_request.submitter %}
    <form id="actionForm" class="form" method='post'>
      {{ action_form.id_ }}
      {{ action_form.type_ }}
      {{ action_form.csrf_token }}
      <div class="form-group">
        <div class="input-group">
          {{ action_form.note(class="form-control") }}
          <div class="input-group-btn" id="actionMenu">
            {# TRANS: This is a button that will add a comment to a request when clicked. #}
            <button type="submit" id="comment" class="btn btn-default">{% trans %}Comment{% endtrans %}</button>
            {% for action in srp_request.valid_actions(current_user) %}
              {% if loop.first %}
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
              <span class="caret"></span>
              {# TRANS: This text is not show and is only used for accesibility purposes. It is used to open a dropdown menu that is normally hidden. #}
              <span class="sr-only">{% trans %}Toggle Dropdown{% endtrans %}</span>
            </button>
            <ul class="dropdown-menu" role="menu" id="actionMenu">
              {% endif %}
              <li><a href="#" id="{{ action.value }}">{{ action.description }}</a></li>
              {% if loop.last %}
            </ul>
              {% endif %}
            {% endfor %}
            </ul>
          </div>
        </div>
      </div>
    </form>
    {% endif %}
    {% block action_list %}
    <div class="list-group" id="actionList">
      {% for action in srp_request.actions %}
      {% with %}
        {% set item_class = 'text-' ~ macros.status_color(action.type_) if macros.status_color(action.type_) != '' %}
        <div class="list-group-item">
          <h4 class="list-group-item-heading{{ ' ' ~ item_class if item_class is defined }}">{{ gettext(action.type_|string) if action.type_ != ActionType.comment }}</h4>
          <blockquote class="list-group-item-text">
            <p class="action-text">{{ action.note|urlize(30) }}</p>
            <footer>{{ action.user.name }} ({{ action.timestamp|datetimeformat }})</footer>
          </blockquote>
        </div>
      {% endwith %}
      {% endfor %}
    </div>
    {% endblock action_list %}
    {% endblock left_col %}
  </div>
  <div class="col-sm-offset-1 col-sm-10 col-md-offset-0 col-md-6 col-lg-5">
    <dl class="dl-horizontal">
      {% block right_col %}
      <dt>{% trans %}Modifiers{% endtrans %}</dt>
      <dd>
        {% block list_modifiers %}
        <div class="panel-group" id="modifierList">
          {% for modifier in srp_request.modifiers %}
          {% if modifier.voided %}
          <div class="panel panel-default">
          {% elif modifier.value < 0 %}
          <div class="panel panel-danger">
          {% elif modifier.value >= 0 %}
          <div class="panel panel-success">
          {% endif %}
            <div class="panel-heading" data-toggle="collapse" data-target="#modifier{{ modifier.id }}">
              {% block modifier_header scoped %}
              {{ '<del>'|safe if modifier.voided }}
              <h4 class="panel-title">
                {{ macros.modifier_value(modifier) }}
              </h4>
              {{ '</del>'|safe if modifier.voided }}
              {% endblock modifier_header %}
            </div>
            <div id="modifier{{ modifier.id }}" class="collapse{{ ' in' if not modifier.voided }}">
              {% if modifier.voided %}
              <div class="panel-body">
                {# TRANS: Modifiers cannot be completely removed, but they can be ignored, or voided out. When voided, they get an extra piece of text saying who voided them and when the modifier was voided. #}
                <del>{{ modifier.note ~ '' if modifier.note }} ({{ gettext('voided by %(voided_name)s at %(voided_timestamp)s', voided_name=modifier.voided_user.name, voided_timestamp=(modifier.voided_timestamp|datetimeformat(format='short'))) }})</del>
              </div>
              {% else %}
              {% if modifier.note %}
              <div class="panel-body">
                {{ modifier.note }}
              </div>
              {% endif %}
              {% endif %}
              <div class="panel-footer">
                {# TRANS: When a modifier is added, the name of the user that added it and the date and time it was added are displayed. #}
                {{ modifier.user }} ({{ modifier.timestamp|datetimeformat('short') }})
              </div>
            </div>
          </div>
          {% endfor %}
        </div>
        {% endblock list_modifiers %}
      </dd>
      {% endblock right_col %}
    </dl>
  </div>
</div>
{% endblock content %}
