ERP/internal/handlers/dashboard.go

24 lines
776 B
Go
Raw Normal View History

2026-02-06 17:35:29 +01:00
package handlers
import (
"net/http"
"erp_system/internal/models"
)
func (h *Handler) Dashboard(w http.ResponseWriter, r *http.Request) {
data := map[string]interface{}{
"Title": "Dashboard",
"Username": h.getUsername(r),
"ActivePage": "dashboard",
"CustomerCount": models.CustomerCount(h.DB),
"OpenOrderCount": models.OrderCountByStatus(h.DB, "draft") + models.OrderCountByStatus(h.DB, "confirmed"),
"PendingInvoices": models.InvoiceCountByStatus(h.DB, "pending"),
"OutstandingAmount": models.InvoiceTotalOutstanding(h.DB),
"RevenueThisMonth": models.RevenueThisMonth(h.DB),
"FulfilledOrders": models.OrderCountByStatus(h.DB, "fulfilled"),
}
2026-02-08 14:20:18 +01:00
h.render(w, r, []string{"layout.html", "dashboard.html"}, data)
2026-02-06 17:35:29 +01:00
}