diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/DailyOrderController.java b/src/main/java/com/bib/essensbestellungsverwaltung/DailyOrderController.java new file mode 100644 index 0000000..feef7cc --- /dev/null +++ b/src/main/java/com/bib/essensbestellungsverwaltung/DailyOrderController.java @@ -0,0 +1,39 @@ +package com.bib.essensbestellungsverwaltung; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.DatePicker; +import javafx.scene.control.ListView; + +import java.time.LocalDate; +import java.util.Calendar; +import java.util.List; + +public class DailyOrderController { + public ListView listView; + public DatePicker datePicker; + + + @FXML + public void initialize() { + datePicker.setValue(LocalDate.now()); + updatePlan(datePicker.getValue().toString()); + } + + public void onChangeDate(ActionEvent actionEvent) { + updatePlan(datePicker.getValue().toString()); + } + + + private void updatePlan(String date){ + System.out.print("Orders from " + date + " : "); + List orders = FoodMgr.getDayOrder(date); + + System.out.println(orders); + + listView.getItems().clear(); + for(String order : orders){ + listView.getItems().add(order); + } + } +} diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/FoodMgr.java b/src/main/java/com/bib/essensbestellungsverwaltung/FoodMgr.java index b3239c4..a35e0c8 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/FoodMgr.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/FoodMgr.java @@ -235,6 +235,9 @@ public class FoodMgr { public static List getDayOrder(String date){ List orders = new ArrayList<>(); FoodPlan food_plan = getFoodPlan(date); + if(food_plan == null){ + return orders; + } String sId = String.valueOf(food_plan.getId()); String[] food_selectionH = {"food_planid","foodid"}; Food[] foodArray = { diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java b/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java index a9a854d..318cd4d 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java @@ -27,13 +27,13 @@ public class WorkerMenuController { @FXML public void initialize() { - changePage("menue-view.fxml"); + changePage("dailyOrder-view.fxml"); setButtonActive(tagesbestellungButton); } @FXML public void onTagesbestellungenClick(MouseEvent mouseEvent) { - changePage("menue-view.fxml"); + changePage("dailyOrder-view.fxml"); setButtonActive(tagesbestellungButton); } diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/dailyOrder-view.fxml b/src/main/resources/com/bib/essensbestellungsverwaltung/dailyOrder-view.fxml index 1087a44..69c586f 100644 --- a/src/main/resources/com/bib/essensbestellungsverwaltung/dailyOrder-view.fxml +++ b/src/main/resources/com/bib/essensbestellungsverwaltung/dailyOrder-view.fxml @@ -1,14 +1,22 @@ - - - + - - + + + + + + + + + + + + + +