176 lines
10 KiB
HTML
176 lines
10 KiB
HTML
{% load i18n %}
|
|
{% load django_ledger %}
|
|
{% load widget_tweaks %}
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded',processElements);
|
|
//document.addEventListener('htmx:afterSwap',processElements);
|
|
|
|
function processElements() {
|
|
window.showPOModal = function(title, actionUrl, buttonText) {
|
|
const modalEl = document.getElementById('POModal');
|
|
if (!modalEl) {
|
|
console.error('Modal element not found');
|
|
return;
|
|
}
|
|
|
|
const modal = bootstrap.Modal.getOrCreateInstance(modalEl);
|
|
document.getElementById('POModalTitle').textContent = title;
|
|
|
|
const modalBody = document.getElementById('POModalBody')
|
|
modalBody.innerHTML = `
|
|
<div class="d-flex justify-content-center gap-3 py-3">
|
|
<a hx-boost="true" class="btn btn-phoenix-primary px-4" href="${actionUrl}">
|
|
<i class="fas fa-check-circle me-2"></i>${buttonText}
|
|
</a>
|
|
<button class="btn btn-phoenix-secondary" data-bs-dismiss="modal">
|
|
<i class="fas fa-times me-2"></i>Cancel
|
|
</button>
|
|
</div>
|
|
`;
|
|
//htmx.process(modalBody)
|
|
modal.show();
|
|
};
|
|
};
|
|
</script>
|
|
{% if not create_po %}
|
|
{% if style == 'po-detail' %}
|
|
<div class="card mb-2">
|
|
<div class="card-header">
|
|
<div class="d-flex align-items-center mb-2 ">
|
|
<span class="me-3 text-primary">{% icon 'uil:bill' 36 %}</span>
|
|
<h2 class="h3 mb-0 text-primary me-4">{{ po_model.po_number }}</h2>
|
|
</div>
|
|
<p>
|
|
<a class="btn btn-phoenix-primary"
|
|
href="{% url 'purchase_order_list' request.dealer.slug request.dealer.entity.slug %}"
|
|
title="Click to view the complete list of Purchase Orders"
|
|
role="button">
|
|
<i class="fas fa-list me-2"></i>{% trans 'PO List' %}
|
|
</a>
|
|
</p>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class='row g-3'>
|
|
<div class='col-12 col-md-3 col-lg-2'>
|
|
<h3 class="h4 mb-0 mb-md-4">
|
|
<span class="badge bg- {% if po_model.is_draft %} success {% elif po_model.is_approved %} success {% elif po_model.is_fulfilled %} primary {% else %} warning {% endif %}">{{ po_model.get_po_status_display }}</span>
|
|
</h3>
|
|
</div>
|
|
<div class='col-12 col-md-4 col-lg-3'>
|
|
{% if po_model.is_draft %}
|
|
<h5 class="h6 text-muted mb-1">{% trans 'Draft Date' %}</h5>
|
|
<p class="h5 mb-3">{{ po_model.date_draft|date }}</p>
|
|
{% endif %}
|
|
{% if po_model.is_review %}
|
|
<h5 class="h6 text-muted mb-1">{% trans 'Review Date' %}</h5>
|
|
<p class="h5 mb-3">{{ po_model.date_in_review|date }}</p>
|
|
{% endif %}
|
|
{% if po_model.is_approved %}
|
|
<h5 class="h6 text-muted mb-1">{% trans 'Approved Date' %}</h5>
|
|
<p class="h5 mb-3">{{ po_model.date_approved|date }}</p>
|
|
{% endif %}
|
|
{% if po_model.is_fulfilled %}
|
|
<h5 class="h6 text-muted mb-1">{% trans 'Fulfilled Date' %}</h5>
|
|
<p class="h5 mb-3">{{ po_model.date_fulfilled|date }}</p>
|
|
{% endif %}
|
|
</div>
|
|
<div class='col-12 col-md-5 col-lg-5'>
|
|
<div class="row text-center g-0">
|
|
<div class="col-6 border-end">
|
|
<div class="p-2">
|
|
<h6 class="text-muted mb-2">{% trans 'PO Amount' %}</h6>
|
|
<h3 class="fw-light mb-0 text-wrap">
|
|
{{ po_model.po_amount | absolute | currency_format }}<span class="icon-saudi_riyal"></span>
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<h6 class="text-muted mb-2">{% trans 'Amount Received' %}</h6>
|
|
<h3 class="fw-light mb-0 text-success text-wrap">
|
|
{{ po_model.po_amount_received | currency_format }}<span class="icon-saudi_riyal"></span>
|
|
</h3>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-footer" hx-boost="false">
|
|
{% if perms.django_ledger.change_purchaseordermodel %}
|
|
<div class="d-flex flex-wrap gap-2 justify-content-between">
|
|
<a href="{% url 'purchase_order_update' dealer_slug=request.dealer.slug entity_slug=entity_slug po_pk=po_model.pk %}"
|
|
class="btn btn-phoenix-primary">
|
|
<i class="fas fa-edit me-2"></i>{% trans 'Update' %}
|
|
</a>
|
|
{% if "detail" not in request.path %}
|
|
<div class="d-flex flex-wrap gap-2">
|
|
{% if po_model.can_draft %}
|
|
<button class="btn btn-phoenix-secondary"
|
|
onclick="showPOModal('Draft PO', '{% url 'po-action-mark-as-draft' request.dealer.slug entity_slug po_model.pk %}', 'Mark As Draft')">
|
|
<i class="fas fa-file me-2"></i>{% trans 'Mark as Draft' %}
|
|
</button>
|
|
{% endif %}
|
|
{% if po_model.can_review %}
|
|
<button class="btn btn-phoenix-warning"
|
|
onclick="showPOModal('Review PO', '{% url 'po-action-mark-as-review' request.dealer.slug entity_slug po_model.pk %}', 'Mark As Review')">
|
|
<i class="fas fa-search me-2"></i>{% trans 'Mark as Review' %}
|
|
</button>
|
|
{% endif %}
|
|
{% if po_model.can_approve %}
|
|
<button class="btn btn-phoenix-success"
|
|
onclick="showPOModal('Approve PO', '{% url 'po-action-mark-as-approved' request.dealer.slug entity_slug po_model.pk %}', 'Mark As Approved')">
|
|
<i class="fas fa-check-circle me-2"></i>{% trans 'Mark as Approved' %}
|
|
</button>
|
|
{% endif %}
|
|
{% if po_model.can_fulfill %}
|
|
{% if not po_ready_to_fulfill %}
|
|
<button disabled class="btn btn-phoenix-primary">
|
|
<i class="fas fa-truck me-2"></i>{% trans 'Mark as Fulfilled' %}
|
|
</button>
|
|
{% else %}
|
|
<button class="btn btn-phoenix-primary"
|
|
onclick="showPOModal('Fulfill PO', '{% url 'po-action-mark-as-fulfilled' request.dealer.slug entity_slug po_model.pk %}', 'Mark As Fulfilled')">
|
|
<i class="fas fa-truck me-2"></i>{% trans 'Mark as Fulfilled' %}
|
|
</button>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if po_model.can_delete %}
|
|
{% if perms.django_ledger.delete_purchaseordermodel %}
|
|
<button class="btn btn-phoenix-danger"
|
|
onclick="showPOModal('Delete PO', '{% url 'po-delete' request.dealer.slug entity_slug po_model.pk %}', 'Delete')">
|
|
<i class="fas fa-trash me-2"></i>{% trans 'Delete' %}
|
|
</button>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if po_model.can_void %}
|
|
<button class="btn btn-phoenix-danger"
|
|
onclick="showPOModal('Void PO', '{% url 'po-action-mark-as-void' request.dealer.slug entity_slug po_model.pk %}', 'Mark As Void')">
|
|
<i class="fas fa-times-circle me-2"></i>{% trans 'Void' %}
|
|
</button>
|
|
{% endif %}
|
|
{% if po_model.can_cancel %}
|
|
<button class="btn btn-phoenix-secondary"
|
|
onclick="showPOModal('Cancel PO', '{% url 'po-action-mark-as-canceled' request.dealer.slug entity_slug po_model.pk %}', 'Mark As Cancelled')">
|
|
<i class="fas fa-ban me-2"></i>{% trans 'Cancel' %}
|
|
</button>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% else %}
|
|
{% if perms.django_ledger.add_purchaseordermodel %}
|
|
<div class="card border-0 shadow-sm text-center py-5">
|
|
<div class="card-body">
|
|
<a href="{% url 'purchase_order_create' request.dealer.slug request.dealer.entity.slug %}"
|
|
class="text-decoration-none">
|
|
<span class="text-muted mb-3 d-inline-block">{% icon "ic:baseline-add-circle-outline" 48 %}</span>
|
|
<h3 class="h4 text-muted">{% trans 'New Purchase Order' %}</h3>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|