Django_Basic_Manufacturing_3/templates/reports/manufacturing_report.html
2025-08-22 17:05:22 +07:00

250 lines
13 KiB
HTML

{% extends "module_base.html" %}
{% load static %}
{% load indonesian_filters %}
{% block title %}Manufacturing Report{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h4 class="card-title mb-0">
<i class="fas fa-cogs me-2"></i>Manufacturing Report
</h4>
</div>
<div class="card-body">
<!-- Report Filters -->
<form method="get" class="row mb-4 g-3">
<div class="col-md-3">
<label for="date_from" class="form-label">Date From</label>
<input type="date" class="form-control" id="date_from" name="date_from" value="{{ date_from }}">
</div>
<div class="col-md-3">
<label for="date_to" class="form-label">Date To</label>
<input type="date" class="form-control" id="date_to" name="date_to" value="{{ date_to }}">
</div>
<div class="col-md-3">
<label for="status" class="form-label">Status</label>
<select class="form-select" id="status" name="status">
<option value="">All Status</option>
<option value="scheduled" {% if request.GET.status == 'scheduled' %}selected{% endif %}>Scheduled</option>
<option value="in_progress" {% if request.GET.status == 'in_progress' %}selected{% endif %}>In Progress</option>
<option value="completed" {% if request.GET.status == 'completed' %}selected{% endif %}>Completed</option>
<option value="cancelled" {% if request.GET.status == 'cancelled' %}selected{% endif %}>Cancelled</option>
</select>
</div>
<div class="col-md-3">
<label for="bom" class="form-label">BOM</label>
<select class="form-select" id="bom" name="bom">
<option value="">All BOMs</option>
{% for bom_item in boms %}
<option value="{{ bom_item.id }}" {% if bom_item.id|stringformat:"s" == request.GET.bom %}selected{% endif %}>{{ bom_item.bom_code }} - {{ bom_item.product.name }}</option>
{% endfor %}
</select>
</div>
</form>
<!-- Summary Cards -->
<div class="row mb-4">
<div class="col-md-3">
<div class="card bg-primary text-white">
<div class="card-body text-center">
<h5 class="card-title">Total Orders</h5>
<h3>{{ total_orders|default:0 }}</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-success text-white">
<div class="card-body text-center">
<h5 class="card-title">Completed</h5>
<h3>{{ completed_orders|default:0 }}</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-warning text-white">
<div class="card-body text-center">
<h5 class="card-title">In Progress</h5>
<h3>{{ in_progress_orders|default:0 }}</h3>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-info text-white">
<div class="card-body text-center">
<h5 class="card-title">Total BOMs</h5>
<h3>{{ total_boms|default:0 }}</h3>
</div>
</div>
</div>
</div>
<!-- Manufacturing Orders Table -->
<div class="card">
<div class="card-header">
<h5 class="mb-0">Manufacturing Orders</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped" id="manufacturing_table">
<thead>
<tr>
<th>MO Number</th>
<th>BOM</th>
<th>Product</th>
<th>Quantity</th>
<th>Status</th>
<th>Start Date</th>
<th>End Date</th>
<th>Total Cost</th>
</tr>
</thead>
<tbody>
{% for order in manufacturing_orders %}
<tr>
<td>{{ order.mo_number }}</td>
<td>{{ order.bom.bom_code }}</td>
<td>{{ order.bom.product.name }}</td>
<td>{{ order.quantity_to_produce }}</td>
<td>
{% if order.status == 'scheduled' %}
<span class="badge bg-secondary">Scheduled</span>
{% elif order.status == 'in_progress' %}
<span class="badge bg-primary">In Progress</span>
{% elif order.status == 'completed' %}
<span class="badge bg-success">Completed</span>
{% elif order.status == 'cancelled' %}
<span class="badge bg-danger">Cancelled</span>
{% endif %}
</td>
<td>{% if order.actual_start_date %}{{ order.actual_start_date|date:"d M Y" }}{% else %}Not started{% endif %}</td>
<td>{% if order.actual_end_date %}{{ order.actual_end_date|date:"d M Y" }}{% else %}Not completed{% endif %}</td>
<td>{{ order.total_cost|format_rupiah }}</td>
</tr>
{% empty %}
<tr>
<td colspan="8" class="text-center text-muted">
No manufacturing orders found for the selected period.
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<!-- BOM Analysis -->
<div class="card mt-4">
<div class="card-header">
<h5 class="mb-0">Bill of Materials Analysis</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>BOM Code</th>
<th>Product</th>
<th>Components</th>
<th>Total Cost</th>
<th>MO Count</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for bom in bom_analysis %}
<tr>
<td>{{ bom.bom_code }}</td>
<td>{{ bom.product.name }}</td>
<td>{{ bom.components_count }}</td>
<td>{{ bom.calculated_total_cost|format_rupiah }}</td>
<td>{{ bom.mo_count }}</td>
<td>
{% if bom.is_active %}
<span class="badge bg-success">Active</span>
{% else %}
<span class="badge bg-secondary">Inactive</span>
{% endif %}
</td>
</tr>
{% empty %}
<tr>
<td colspan="6" class="text-center text-muted">
No BOMs found.
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<!-- Export Options -->
<div class="mt-4 text-center">
<div class="btn-group">
<button class="btn btn-outline-primary" onclick="exportToExcel()">
<i class="fas fa-file-excel me-2"></i>Export to Excel
</button>
<button class="btn btn-outline-danger" onclick="exportToPDF()">
<i class="fas fa-file-pdf me-2"></i>Export to PDF
</button>
<button class="btn btn-outline-secondary" onclick="printReport()">
<i class="fas fa-print me-2"></i>Print Report
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Set default date range (last 30 days)
const today = new Date();
const thirtyDaysAgo = new Date();
thirtyDaysAgo.setDate(today.getDate() - 30);
const dateFromInput = document.getElementById('date_from');
const dateToInput = document.getElementById('date_to');
if (dateFromInput && !dateFromInput.value) {
dateFromInput.value = thirtyDaysAgo.toISOString().split('T')[0];
}
if (dateToInput && !dateToInput.value) {
dateToInput.value = today.toISOString().split('T')[0];
}
// Auto-submit form when filters change
document.querySelectorAll('select').forEach(select => {
select.addEventListener('change', function() {
this.closest('form').submit();
});
});
});
function exportToExcel() {
// Get current filter parameters
const urlParams = new URLSearchParams(window.location.search);
urlParams.set('export', 'excel');
// Create export URL with current filters
const exportUrl = window.location.pathname + '?' + urlParams.toString();
window.location.href = exportUrl;
}
function exportToPDF() {
alert('PDF export functionality would be implemented here');
}
function printReport() {
window.print();
}
</script>
{% endblock %}