{% extends "order/order_base.html" %}

{% load inventree_extras %}
{% load i18n %}
{% load static %}
{% load markdownify %}

{% block menubar %}
{% include 'order/po_navbar.html' with tab='notes' %}
{% endblock %}

{% block heading %}
{% trans "Order Notes" %}
{% endblock %}

{% block details %}

{% if editing %}
<form method='POST'>
    {% csrf_token %}

    {{ form }}
    <hr>
    <input type='submit' value='{% trans "Save" %}'/>
</form>

{{ form.media }}

{% else %}
{% if roles.purchase_order.change %}
<button title='{% trans "Edit notes" %}' class='btn btn-default action-button' id='edit-notes'><span class='fas fa-edit'></span></button>
{% endif %}
{% endif %}
<div class='panel panel-default'>
    <div class='panel-content'>
        {{ order.notes | markdownify }}
    </div>
</div>

{% endblock %}

{% block js_ready %}

{{ block.super }}

{% if editing %}
{% else %}
$("#edit-notes").click(function() {
    location.href = "{% url 'po-notes' order.id %}?edit=1";
});
{% endif %}

{% endblock %}