';
+ }
+}
+
+async function saveAssociation(event) {
+ event.preventDefault();
+ const projectId = document.getElementById('assoc-project-id').value;
+ const payload = {
+ project_id: parseInt(projectId, 10),
+ item_id: parseInt(document.getElementById('assoc-item').value, 10),
+ quantity: parseInt(document.getElementById('assoc-qty').value, 10)
+ };
+
+ await apiRequest('/api/association', 'POST', payload);
+ document.getElementById('assoc-qty').value = '';
+ await reloadAssociationTable(projectId);
+}
+
+async function deleteAssociation(assocId, projectId) {
+ if (confirm("Remove this item from the project?")) {
+ await apiRequest(`/api/association?id=${assocId}`, 'DELETE');
+ await reloadAssociationTable(projectId);
+ }
}
\ No newline at end of file
diff --git a/frontend/htmx/contents/dash/inventory.html b/frontend/htmx/contents/dash/inventory.html
index 577f4c0..76f8cc1 100644
--- a/frontend/htmx/contents/dash/inventory.html
+++ b/frontend/htmx/contents/dash/inventory.html
@@ -36,9 +36,6 @@
-
-
-
@@ -46,4 +43,46 @@
+
+
+
+
Manage Stock
+
+
+
Current Locations
+
+
+
+
+
Location
+
Quantity
+
+
+
+
+
+
+
+
+
+
Update Stock
+
+
+
+
+
{{ end }}
\ No newline at end of file
diff --git a/frontend/htmx/contents/dash/projects.html b/frontend/htmx/contents/dash/projects.html
index ffcdd96..f4c08be 100644
--- a/frontend/htmx/contents/dash/projects.html
+++ b/frontend/htmx/contents/dash/projects.html
@@ -39,4 +39,46 @@
+
+
+
+
Manage Project Items
+
+
+
Allocated Items
+
+
+
+
+
Item
+
Quantity
+
+
+
+
+
+
+
+
+
+
Allocate New Item
+
+
+
+
+
{{ end }}
\ No newline at end of file
diff --git a/models/inventory.go b/models/inventory.go
index cdc4a73..becb799 100644
--- a/models/inventory.go
+++ b/models/inventory.go
@@ -5,7 +5,8 @@ type Item struct {
Name string `json:"name"`
Category string `json:"category"`
Description string `json:"description"`
- TotalQuantity int `json:"total_quantity"`
+ TotalQuantity int `json:"total_quantity"` // Berechnet aus der Summe aller Stocks
+ FreeQuantity int `json:"free_quantity"` // TotalQuantity minus Summe aller Projekt-Zuweisungen
}
type Location struct {
@@ -20,10 +21,19 @@ type Project struct {
}
type Stock struct {
- ID int `json:"id"`
- ItemID int `json:"item_id"`
- LocationID int `json:"location_id"`
- Quantity int `json:"quantity"`
+ ID int `json:"id"`
+ ItemID int `json:"item_id"`
+ LocationID int `json:"location_id"`
+ Quantity int `json:"quantity"`
+ LocationName string `json:"location_name"` // Used to display the location in the modal table
+}
+
+type Association struct {
+ ID int `json:"id"`
+ ProjectID int `json:"project_id"`
+ ItemID int `json:"item_id"`
+ Quantity int `json:"quantity"`
+ ItemName string `json:"item_name"` // Used to display the item name in the modal table
}
type ProjectItem struct {