Django_Basic_Manufacturing_3/templates/purchasing/po_detail.html
2025-08-22 17:05:22 +07:00

218 lines
9.9 KiB
HTML

{% extends 'base.html' %}
{% load indonesian_filters %}
{% block title %}Purchase Order {{ po.po_number }} - Manufacturing App{% endblock %}
{% block content %}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Purchase Order: {{ po.po_number }}</h1>
<div class="btn-toolbar mb-2 mb-md-0">
<a href="{% url 'purchasing:edit_po' po.po_number %}" class="btn btn-outline-secondary">
<i class="fas fa-edit"></i> Edit
</a>
<a href="{% url 'purchasing:delete_po' po.po_number %}" class="btn btn-outline-danger ms-2">
<i class="fas fa-trash"></i> Delete
</a>
<a href="{% url 'purchasing:po_list' %}" class="btn btn-outline-primary ms-2">
<i class="fas fa-arrow-left"></i> Back to List
</a>
</div>
</div>
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
{% endif %}
<div class="row">
<div class="col-lg-8">
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0">Purchase Order Information</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-6">
<table class="table table-borderless">
<tr>
<th width="40%">PO Number:</th>
<td>{{ po.po_number }}</td>
</tr>
<tr>
<th>Supplier:</th>
<td><strong>{{ po.supplier.name }}</strong></td>
</tr>
<tr>
<th>Order Date:</th>
<td>{{ po.order_date|date:"M d, Y" }}</td>
</tr>
<tr>
<th>Expected Delivery:</th>
<td>
{% if po.expected_delivery_date %}
{{ po.expected_delivery_date|date:"M d, Y" }}
{% else %}
<em>Not specified</em>
{% endif %}
</td>
</tr>
<tr>
<th>Status:</th>
<td>
{% if po.status == 'ordered' %}
<span class="badge bg-warning">Ordered</span>
{% elif po.status == 'completed' %}
<span class="badge bg-success">Completed</span>
{% elif po.status == 'cancelled' %}
<span class="badge bg-danger">Cancelled</span>
{% else %}
<span class="badge bg-secondary">{{ po.get_status_display }}</span>
{% endif %}
</td>
</tr>
</table>
</div>
<div class="col-md-6">
<table class="table table-borderless">
<tr>
<th width="40%">Subtotal:</th>
<td>{{ po.subtotal|format_rupiah }}</td>
</tr>
<tr>
<th>Tax (11%):</th>
<td>{{ po.tax_amount|format_rupiah }}</td>
</tr>
<tr class="table-info">
<th><strong>Total Amount:</strong></th>
<td><strong>{{ po.total_amount|format_rupiah }}</strong></td>
</tr>
<tr>
<th>Items Count:</th>
<td>{{ po.items.count }} items</td>
</tr>
<tr>
<th>Created:</th>
<td>{{ po.created_at|date:"M d, Y H:i" }}</td>
</tr>
</table>
</div>
</div>
{% if po.notes %}
<div class="mt-3">
<h6>Notes:</h6>
<p class="mb-0">{{ po.notes|linebreaks }}</p>
</div>
{% endif %}
</div>
</div>
<div class="card">
<div class="card-header">
<h5 class="mb-0">Order Items</h5>
</div>
<div class="card-body">
{% if po.items.all %}
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead class="table-dark">
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total Price</th>
<th>Received</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for item in po.items.all %}
<tr>
<td>
<strong>{{ item.product.name }}</strong><br>
<small class="text-muted">{{ item.product.code }}</small>
</td>
<td>{{ item.quantity|floatformat:0 }}</td>
<td>{{ item.unit_price|format_rupiah }}</td>
<td>{{ item.total_price|format_rupiah }}</td>
<td>
{% if item.received_quantity > 0 %}
<span class="badge bg-info">{{ item.received_quantity|floatformat:0 }}</span>
{% else %}
<span class="badge bg-secondary">0</span>
{% endif %}
</td>
<td>
{% if item.received_quantity >= item.quantity %}
<span class="badge bg-success">Fully Received</span>
{% elif item.received_quantity > 0 %}
<span class="badge bg-warning">Partially Received</span>
{% else %}
<span class="badge bg-secondary">Not Received</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<p class="text-muted">No items in this order.</p>
{% endif %}
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0">Supplier Information</h5>
</div>
<div class="card-body">
<h6>{{ po.supplier.name }}</h6>
<p class="mb-1"><i class="fas fa-map-marker-alt"></i> {{ po.supplier.address|default:"No address" }}</p>
{% if po.supplier.phone %}
<p class="mb-1"><i class="fas fa-phone"></i> {{ po.supplier.phone }}</p>
{% endif %}
{% if po.supplier.email %}
<p class="mb-1"><i class="fas fa-envelope"></i> {{ po.supplier.email }}</p>
{% endif %}
<a href="{% url 'purchasing:supplier_detail' po.supplier.id %}" class="btn btn-sm btn-outline-primary">
View Supplier Details
</a>
</div>
</div>
<div class="card">
<div class="card-header">
<h5 class="mb-0">Quick Actions</h5>
</div>
<div class="card-body">
{% if po.status == 'ordered' %}
<a href="{% url 'purchasing:edit_po' po.po_number %}" class="btn btn-warning w-100 mb-2">
<i class="fas fa-edit"></i> Edit Order
</a>
<a href="{% url 'purchasing:approve_po' po.po_number %}" class="btn btn-success w-100 mb-2">
<i class="fas fa-check"></i> Approve Order
</a>
{% endif %}
{% if po.status == 'ordered' or po.status == 'approved' %}
<a href="{% url 'purchasing:create_gr' po.po_number %}" class="btn btn-info w-100 mb-2">
<i class="fas fa-truck-loading"></i> Create Goods Receipt
</a>
{% endif %}
<a href="{% url 'purchasing:delete_po' po.po_number %}" class="btn btn-danger w-100 mb-2">
<i class="fas fa-trash"></i> Delete Order
</a>
<a href="{% url 'purchasing:po_list' %}" class="btn btn-secondary w-100">
<i class="fas fa-list"></i> View All Orders
</a>
</div>
</div>
</div>
</div>
{% endblock %}