{% extends "base.html" %}

{% block title %}Project Summary - {{ project.project_title }}{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="card shadow">
        <div class="card-header bg-primary text-white d-flex justify-content-between align-items-center">
            <h4 class="mb-0">Project Summary: {{ project.project_title }}</h4>
            {% if project.parent %}
                <span class="badge bg-secondary">Child of: {{ project.parent.project_title }}</span>
            {% endif %}
        </div>
        <div class="card-body">

            <!-- Project Details -->
            <div class="row mb-4">
                <div class="col-md-4"><strong>Project Type:</strong> {{ project.project_type }}</div>
                <div class="col-md-4"><strong>Start Date:</strong> {{ project.start_date }}</div>
                <div class="col-md-4"><strong>End Date:</strong> {{ project.end_date|default:"Ongoing" }}</div>
            </div>

            <!-- Financial Summary -->
            <h5 class="mb-3">Financial Summary</h5>
            <table class="table table-bordered">
                <tbody>
                    <tr>
                        <th>Total Purchases</th>
                        <td>{{ total_purchases|floatformat:2 }}</td>
                    </tr>
                    <tr>
                        <th>Total Sales</th>
                        <td>{{ total_sales|floatformat:2 }}</td>
                    </tr>
                    <tr>
                        <th>Total Expenses</th>
                        <td>{{ total_expenses|floatformat:2 }}</td>
                    </tr>
                    <tr>
                        <th>Total Revenue</th>
                        <td>{{ total_revenue|floatformat:2 }}</td>
                    </tr>
                    <tr class="table-active">
                        <th>Net Profit / Loss</th>
                        <td><strong>{{ net_profit|floatformat:2 }}</strong></td>
                    </tr>
                </tbody>
            </table>

            <!-- Stock Summary -->
            <h5 class="mt-4 mb-3">Stock Summary</h5>
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>Total Stock In</th>
                        <th>Total Stock Out</th>
                        <th>Current Stock</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>{{ stock_in|floatformat:2 }}</td>
                        <td>{{ stock_out|floatformat:2 }}</td>
                        <td><strong>{{ current_stock|floatformat:2 }}</strong></td>
                    </tr>
                </tbody>
            </table>

            <div class="text-end">
                <a href="{% url 'project_dashboard' project.id %}" class="btn btn-secondary mt-3">
                    <i class="bi bi-arrow-left"></i> Back to Dashboard
                </a>
            </div>

        </div>
    </div>
</div>
{% endblock %}
