This commit is contained in:
lubiana 2025-05-31 21:43:13 +02:00
parent e958163a4a
commit b8a5a1ff58
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
79 changed files with 15113 additions and 0 deletions

View file

@ -0,0 +1,172 @@
{% extends 'layout.twig' %}
{% block title %}Inventory History - {{ parent() }}{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col">
<h2>
{% if drinkType is defined %}
Inventory History for {{ drinkType.name }}
{% else %}
Inventory History
{% endif %}
</h2>
</div>
<div class="col-auto">
<div class="btn-group" role="group">
<a href="/inventory" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Inventory
</a>
{% if drinkType is defined %}
<a href="/inventory/history" class="btn btn-info">
<i class="fas fa-list"></i> All History
</a>
{% endif %}
<a href="/inventory/update" class="btn btn-primary">
<i class="fas fa-sync"></i> Update Stock
</a>
</div>
</div>
</div>
{% if inventoryRecords is empty %}
<div class="alert alert-info">
No inventory records found.
</div>
{% else %}
<div class="card">
<div class="card-header">
<div class="row">
<div class="col">
<h5 class="card-title mb-0">Stock Change History</h5>
</div>
<div class="col-auto">
<div class="dropdown">
<button class="btn btn-sm btn-outline-secondary dropdown-toggle" type="button" id="filterDropdown" data-bs-toggle="dropdown" aria-expanded="false">
Filter
</button>
<ul class="dropdown-menu" aria-labelledby="filterDropdown">
<li><a class="dropdown-item" href="/inventory/history">All Records</a></li>
<li><hr class="dropdown-divider"></li>
<li><h6 class="dropdown-header">By Drink Type</h6></li>
{% for type in drinkTypes|default([]) %}
<li><a class="dropdown-item" href="/inventory/history/{{ type.id }}">{{ type.name }}</a></li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Date</th>
{% if drinkType is not defined %}
<th>Drink Type</th>
{% endif %}
<th>Previous Quantity</th>
<th>New Quantity</th>
<th>Change</th>
</tr>
</thead>
<tbody>
{% for record in inventoryRecords %}
<tr>
<td>{{ record.createdAt|date('Y-m-d H:i:s') }}</td>
{% if drinkType is not defined %}
<td>
<a href="/drink-types/{{ record.drinkType.id }}">
{{ record.drinkType.name }}
</a>
</td>
{% endif %}
<td>{{ record.previousQuantity|default('-') }}</td>
<td>{{ record.quantity }}</td>
<td>
{% if record.change is defined %}
{% if record.change > 0 %}
<span class="text-success">+{{ record.change }}</span>
{% elseif record.change < 0 %}
<span class="text-danger">{{ record.change }}</span>
{% else %}
<span class="text-muted">0</span>
{% endif %}
{% else %}
<span class="text-muted">Initial</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card-footer">
<small class="text-muted">Showing {{ inventoryRecords|length }} records</small>
</div>
</div>
{% if drinkType is defined %}
<div class="row mt-4">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">Stock Level Trend</h5>
</div>
<div class="card-body">
<p class="text-muted">Stock level trend visualization would be displayed here.</p>
<div class="alert alert-info">
<i class="fas fa-info-circle"></i> This is a placeholder for a chart showing the stock level trend over time.
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">Drink Type Information</h5>
</div>
<div class="card-body">
<table class="table table-bordered">
<tr>
<th style="width: 30%">Name</th>
<td>{{ drinkType.name }}</td>
</tr>
<tr>
<th>Description</th>
<td>{{ drinkType.description|default('No description provided') }}</td>
</tr>
<tr>
<th>Desired Stock</th>
<td>{{ drinkType.desiredStock }}</td>
</tr>
<tr>
<th>Current Stock</th>
<td>
{% if drinkType.currentStock is defined %}
{% if drinkType.currentStock < drinkType.desiredStock %}
<span class="text-danger">{{ drinkType.currentStock }}</span>
{% else %}
<span class="text-success">{{ drinkType.currentStock }}</span>
{% endif %}
{% else %}
Not available
{% endif %}
</td>
</tr>
</table>
<div class="mt-3">
<a href="/drink-types/{{ drinkType.id }}" class="btn btn-sm btn-info">
<i class="fas fa-eye"></i> View Full Details
</a>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endif %}
{% endblock %}

View file

@ -0,0 +1,175 @@
{% extends 'layout.twig' %}
{% block title %}Inventory Overview - {{ parent() }}{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col">
<h2>Inventory Overview</h2>
</div>
<div class="col-auto">
<div class="btn-group" role="group">
<a href="/inventory/update" class="btn btn-primary">
<i class="fas fa-sync"></i> Update Stock
</a>
<a href="/inventory/history" class="btn btn-info">
<i class="fas fa-history"></i> View History
</a>
<a href="/orders/create-from-stock" class="btn btn-success">
<i class="fas fa-shopping-cart"></i> Create Order
</a>
</div>
</div>
</div>
{% if stockLevels is empty %}
<div class="alert alert-info">
No drink types found in inventory. <a href="/drink-types/create">Add a drink type</a> to get started.
</div>
{% else %}
<div class="row">
<div class="col-md-8">
<div class="card mb-4">
<div class="card-header">
<h5 class="card-title mb-0">Current Stock Levels</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Drink Type</th>
<th>Current Stock</th>
<th>Desired Stock</th>
<th>Difference</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for item in stockLevels %}
<tr>
<td>
<a href="/drink-types/{{ item.drinkType.id }}">
{{ item.drinkType.name }}
</a>
</td>
<td>{{ item.currentStock }}</td>
<td>{{ item.drinkType.desiredStock }}</td>
<td>
{% set difference = item.currentStock - item.drinkType.desiredStock %}
{% if difference < 0 %}
<span class="text-danger">{{ difference }}</span>
{% elseif difference > 0 %}
<span class="text-success">+{{ difference }}</span>
{% else %}
<span class="text-muted">0</span>
{% endif %}
</td>
<td>
{% if item.currentStock < item.drinkType.desiredStock %}
<span class="badge bg-danger">Low Stock</span>
{% elseif item.currentStock == item.drinkType.desiredStock %}
<span class="badge bg-success">Optimal</span>
{% else %}
<span class="badge bg-info">Excess</span>
{% endif %}
</td>
<td>
<div class="btn-group btn-group-sm" role="group">
<a href="/inventory/history/{{ item.drinkType.id }}" class="btn btn-outline-secondary">
<i class="fas fa-history"></i>
</a>
<a href="/inventory/update" class="btn btn-outline-primary">
<i class="fas fa-edit"></i>
</a>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4">
<div class="card-header bg-primary text-white">
<h5 class="card-title mb-0">Inventory Summary</h5>
</div>
<div class="card-body">
{% set totalItems = stockLevels|length %}
{% set lowStockCount = 0 %}
{% set optimalCount = 0 %}
{% set excessCount = 0 %}
{% for item in stockLevels %}
{% if item.currentStock < item.drinkType.desiredStock %}
{% set lowStockCount = lowStockCount + 1 %}
{% elseif item.currentStock == item.drinkType.desiredStock %}
{% set optimalCount = optimalCount + 1 %}
{% else %}
{% set excessCount = excessCount + 1 %}
{% endif %}
{% endfor %}
<div class="mb-3">
<h6>Total Drink Types: {{ totalItems }}</h6>
</div>
<div class="mb-3">
<div class="d-flex justify-content-between">
<span>Low Stock:</span>
<span class="text-danger">{{ lowStockCount }}</span>
</div>
<div class="progress">
<div class="progress-bar bg-danger" role="progressbar" style="width: {{ (lowStockCount / totalItems * 100)|round }}%"></div>
</div>
</div>
<div class="mb-3">
<div class="d-flex justify-content-between">
<span>Optimal Stock:</span>
<span class="text-success">{{ optimalCount }}</span>
</div>
<div class="progress">
<div class="progress-bar bg-success" role="progressbar" style="width: {{ (optimalCount / totalItems * 100)|round }}%"></div>
</div>
</div>
<div class="mb-3">
<div class="d-flex justify-content-between">
<span>Excess Stock:</span>
<span class="text-info">{{ excessCount }}</span>
</div>
<div class="progress">
<div class="progress-bar bg-info" role="progressbar" style="width: {{ (excessCount / totalItems * 100)|round }}%"></div>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-header bg-success text-white">
<h5 class="card-title mb-0">Quick Actions</h5>
</div>
<div class="card-body">
<div class="d-grid gap-2">
<a href="/inventory/update" class="btn btn-primary">
<i class="fas fa-sync"></i> Update Stock
</a>
<a href="/orders/create-from-stock" class="btn btn-success">
<i class="fas fa-shopping-cart"></i> Create Order from Stock Levels
</a>
<a href="/inventory/low-stock" class="btn btn-warning">
<i class="fas fa-exclamation-triangle"></i> View Low Stock Items
</a>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}

View file

@ -0,0 +1,159 @@
{% extends 'layout.twig' %}
{% block title %}Low Stock Items - {{ parent() }}{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col">
<h2>Low Stock Items</h2>
</div>
<div class="col-auto">
<div class="btn-group" role="group">
<a href="/inventory" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Inventory
</a>
<a href="/inventory/update" class="btn btn-primary">
<i class="fas fa-sync"></i> Update Stock
</a>
<a href="/orders/create-from-stock" class="btn btn-success">
<i class="fas fa-shopping-cart"></i> Create Order
</a>
</div>
</div>
</div>
{% if lowStockItems is empty %}
<div class="alert alert-success">
<i class="fas fa-check-circle"></i> All items are at or above their desired stock levels.
</div>
{% else %}
<div class="card">
<div class="card-header bg-warning text-white">
<h5 class="card-title mb-0">Items Below Desired Stock Levels</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>Drink Type</th>
<th>Current Stock</th>
<th>Desired Stock</th>
<th>Difference</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for item in lowStockItems %}
<tr>
<td>
<a href="/drink-types/{{ item.drinkType.id }}">
{{ item.drinkType.name }}
</a>
</td>
<td>{{ item.currentStock }}</td>
<td>{{ item.drinkType.desiredStock }}</td>
<td class="text-danger">{{ item.currentStock - item.drinkType.desiredStock }}</td>
<td>
{% set percentage = (item.currentStock / item.drinkType.desiredStock * 100)|round %}
{% if percentage < 25 %}
<span class="badge bg-danger">Critical ({{ percentage }}%)</span>
{% elseif percentage < 50 %}
<span class="badge bg-warning">Low ({{ percentage }}%)</span>
{% else %}
<span class="badge bg-info">Below Target ({{ percentage }}%)</span>
{% endif %}
</td>
<td>
<div class="btn-group btn-group-sm" role="group">
<a href="/inventory/history/{{ item.drinkType.id }}" class="btn btn-outline-secondary">
<i class="fas fa-history"></i>
</a>
<a href="/inventory/update" class="btn btn-outline-primary">
<i class="fas fa-edit"></i>
</a>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="card-footer">
<div class="d-flex justify-content-between align-items-center">
<small class="text-muted">Showing {{ lowStockItems|length }} items below desired stock levels</small>
<a href="/orders/create-from-stock" class="btn btn-success">
<i class="fas fa-shopping-cart"></i> Create Order from Stock Levels
</a>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">Recommended Actions</h5>
</div>
<div class="card-body">
<ul class="list-group">
<li class="list-group-item">
<i class="fas fa-shopping-cart text-success"></i> Create an order to replenish stock
</li>
<li class="list-group-item">
<i class="fas fa-chart-line text-info"></i> Review consumption patterns
</li>
<li class="list-group-item">
<i class="fas fa-cog text-primary"></i> Adjust desired stock levels if needed
</li>
</ul>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">Stock Level Summary</h5>
</div>
<div class="card-body">
<div class="alert alert-warning">
<i class="fas fa-exclamation-triangle"></i> {{ lowStockItems|length }} items are below their desired stock levels.
</div>
{% set criticalCount = 0 %}
{% set lowCount = 0 %}
{% set belowTargetCount = 0 %}
{% for item in lowStockItems %}
{% set percentage = (item.currentStock / item.drinkType.desiredStock * 100)|round %}
{% if percentage < 25 %}
{% set criticalCount = criticalCount + 1 %}
{% elseif percentage < 50 %}
{% set lowCount = lowCount + 1 %}
{% else %}
{% set belowTargetCount = belowTargetCount + 1 %}
{% endif %}
{% endfor %}
<div class="mt-3">
<div class="d-flex justify-content-between mb-1">
<span>Critical (< 25%):</span>
<span class="text-danger">{{ criticalCount }}</span>
</div>
<div class="d-flex justify-content-between mb-1">
<span>Low (25-50%):</span>
<span class="text-warning">{{ lowCount }}</span>
</div>
<div class="d-flex justify-content-between mb-1">
<span>Below Target (> 50%):</span>
<span class="text-info">{{ belowTargetCount }}</span>
</div>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}

View file

@ -0,0 +1,88 @@
{% extends 'layout.twig' %}
{% import 'components/form.twig' as form %}
{% block title %}Update Stock - {{ parent() }}{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col">
<h2>Update Stock Levels</h2>
</div>
<div class="col-auto">
<a href="/inventory" class="btn btn-secondary">
<i class="fas fa-arrow-left"></i> Back to Inventory
</a>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">Update Single Item</h5>
</div>
<div class="card-body">
{{ form.errors(error) }}
<form action="/inventory/update" method="post">
<div class="form-group mb-3">
<label for="drink_type_id">Drink Type</label>
<select id="drink_type_id" name="drink_type_id" class="form-control" required>
<option value="">-- Select Drink Type --</option>
{% for drinkType in drinkTypes %}
<option value="{{ drinkType.id }}">{{ drinkType.name }}</option>
{% endfor %}
</select>
</div>
<div class="form-group mb-3">
<label for="quantity">New Quantity</label>
<input type="number" id="quantity" name="quantity" class="form-control" min="0" required>
<small class="form-text text-muted">Enter the new total quantity, not the amount to add/remove.</small>
</div>
<div class="form-group">
{{ form.submit('Update Stock') }}
</div>
</form>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header bg-info text-white">
<h5 class="card-title mb-0">Stock Update Tips</h5>
</div>
<div class="card-body">
<div class="alert alert-info">
<h6 class="alert-heading">How to update stock:</h6>
<ol>
<li>Select the drink type you want to update</li>
<li>Enter the <strong>total</strong> current quantity (not the difference)</li>
<li>Click "Update Stock" to save the changes</li>
</ol>
</div>
<div class="alert alert-warning">
<h6 class="alert-heading">Important Notes:</h6>
<ul>
<li>Stock updates are logged in the inventory history</li>
<li>The system will calculate the difference from the previous stock level</li>
<li>If stock falls below desired levels, it will appear in low stock alerts</li>
</ul>
</div>
<div class="mt-4">
<h6>Quick Links:</h6>
<ul>
<li><a href="/inventory/history">View inventory history</a></li>
<li><a href="/inventory/low-stock">View low stock items</a></li>
<li><a href="/orders/create-from-stock">Create order from stock levels</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
{% endblock %}