{% extends 'buybacks/page.html' %}
{% load i18n %}
{% load humanize %}
{% load bootstrap %}
{% load static %}
{% load dict %}
{% load number %}

{% block body %}
<h4>{{ program.name }} - Buyback Program</h4>

{% if value|not_empty %}
<div class="table-responsive" style="margin: 20px 0;">
    <p class="text-muted">Based on the contents you have given us, we have calculated them to be of the following value.</p>
    <p class="text-warning">Please click the <strong>Notify</strong> button to let us know you will be sending the contract.</p>

    <table id="value" style="width: 60%; margin: 20px auto;" class="table table-striped table-condensed">
        <thead>
            <tr>
                <th style="width: 55%">Item</th>
                <th style="width: 15%; text-align: center;">Quantity</th>
                <th style="width: 30%; text-align: center;">Value</th>
            </tr>
        </thead>
        <tbody>
            {% for item in value %}
            <tr>
                <td data-type-id="{{ typeids|lookup:item }}">{{ item }}</td>
                <td style="text-align: right;">{{ data|lookup:item|format_number:0 }}</td>
                <td style="text-align: right;">{{ value|lookup:item|format_number:2 }} ISK</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

    <div style="text-align: center;">
        <p class="text-muted">Total Contract Value: <span class="text-primary" id="total">{{ total|format_number:0 }}</span> ISK</p>
        <button id="notify" data-program-location="{{ program_location.id }}" data-url="{% url 'buybacks:program_notify' program_pk=program.id %}" class="btn btn-warning btn-sm">Notify</button>
    </div>
</div>
{% endif %}

<form class="form" action="{% url 'buybacks:program_calculate' program_pk=program.id %}" method="POST">
    {% csrf_token %}
    {{ form|bootstrap }}
    <button type="submit" class="btn btn-primary">Calculate</button>
  </form>
{% endblock %}

{% block extra_javascript %}
<script type="text/javascript" src="{% static 'buybacks/js/notify.js' %}"></script>
{% endblock %}

{% block extra_css %}
{% endblock %}

{% block extra_script %}
{% endblock %}
