Add sales-month planning for crops/products and fix today task label format

This commit is contained in:
Kai
2026-02-16 14:03:19 +01:00
parent 723e9142b2
commit b1c502a919
8 changed files with 216 additions and 15 deletions

View File

@@ -31,6 +31,16 @@ func (a *App) handleDashboard(w http.ResponseWriter, r *http.Request) {
http.Error(w, "plans read failed", http.StatusInternalServerError)
return
}
crops, err := a.listCrops()
if err != nil {
http.Error(w, "crops read failed", http.StatusInternalServerError)
return
}
products, err := a.listProducts()
if err != nil {
http.Error(w, "products read failed", http.StatusInternalServerError)
return
}
stepMap, err := a.listCropStepsMap()
if err != nil {
http.Error(w, "steps read failed", http.StatusInternalServerError)
@@ -54,8 +64,8 @@ func (a *App) handleDashboard(w http.ResponseWriter, r *http.Request) {
},
Settings: settings,
CurrentMonth: monthNames[settings.CurrentMonth-1],
TodayTasks: buildTasksForDay(plans, stepMap, customTasks, doneMap, settings.CurrentMonth, settings.CurrentDay),
Calendar: buildCalendar(plans, stepMap, customTasks, doneMap, settings.CurrentMonth, settings.CurrentDay, settings.DaysPerMonth, 14),
TodayTasks: buildTasksForDay(plans, crops, products, stepMap, customTasks, doneMap, settings.CurrentMonth, settings.CurrentDay),
Calendar: buildCalendar(plans, crops, products, stepMap, customTasks, doneMap, settings.CurrentMonth, settings.CurrentDay, settings.DaysPerMonth, 14),
PlanningCount: len(plans),
}
a.renderTemplate(w, "templates/dashboard.html", data)
@@ -98,6 +108,11 @@ func (a *App) handleCropsPage(w http.ResponseWriter, r *http.Request) {
http.Error(w, "steps read failed", http.StatusInternalServerError)
return
}
products, err := a.listProducts()
if err != nil {
http.Error(w, "products read failed", http.StatusInternalServerError)
return
}
data := CropsPage{
BasePage: BasePage{
ActivePath: "/crops",
@@ -106,6 +121,7 @@ func (a *App) handleCropsPage(w http.ResponseWriter, r *http.Request) {
},
Crops: crops,
CropSteps: steps,
Products: products,
}
a.renderTemplate(w, "templates/crops.html", data)
}