From f64dc7751f5c1601633e619f81fe0835bd6c9aba Mon Sep 17 00:00:00 2001 From: Johannes Kantz <67144859+JohannesKantz@users.noreply.github.com> Date: Sun, 5 Feb 2023 20:20:58 +0100 Subject: [PATCH] fix: tagesbestellung locked foodplan --- .../DailyOrderController.java | 41 ++++++++++++++++++- .../dailyOrder-view.fxml | 1 + 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/DailyOrderController.java b/src/main/java/com/bib/essensbestellungsverwaltung/DailyOrderController.java index feef7cc..7409d28 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/DailyOrderController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/DailyOrderController.java @@ -2,16 +2,19 @@ package com.bib.essensbestellungsverwaltung; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.scene.control.Button; import javafx.scene.control.DatePicker; import javafx.scene.control.ListView; import java.time.LocalDate; +import java.util.ArrayList; import java.util.Calendar; import java.util.List; public class DailyOrderController { public ListView listView; public DatePicker datePicker; + public Button sendButton; @FXML @@ -26,14 +29,48 @@ public class DailyOrderController { private void updatePlan(String date){ + listView.getItems().clear(); System.out.print("Orders from " + date + " : "); - List orders = FoodMgr.getDayOrder(date); + List orders = new ArrayList<>(); + FoodPlan food_plan = FoodMgr.getFoodPlan(date); + if(food_plan == null){ + sendButton.setVisible(false); + return; + } + sendButton.setVisible(true); + if(food_plan.isSent()){ + sendButton.setDisable(true); + sendButton.setText("Bestellung wurde Gesendet"); + }else { + sendButton.setDisable(false); + sendButton.setText("Bestellung senden"); + } + String sId = String.valueOf(food_plan.getId()); + String[] food_selectionH = {"food_planid","foodid"}; + Food[] foodArray = { + food_plan.getFoodVegan(), + food_plan.getFoodSecond(), + food_plan.getDessertVegan(), + food_plan.getDessertSecond() + }; + for(int i = 0; i < 4; i++){ + String foodName = foodArray[i].getName(); + String[] food_selectionD = {sId, String.valueOf(foodArray[i].getId())}; + int count = Database.count("food_selection",food_selectionH,food_selectionD); + orders.add(count+" X "+foodName); + } System.out.println(orders); - listView.getItems().clear(); + for(String order : orders){ listView.getItems().add(order); } } + + public void onSendButton(ActionEvent actionEvent) { + FoodMgr.getDayOrder(datePicker.getValue().toString()); + sendButton.setDisable(true); + sendButton.setText("Bestellung wurde Gesendet"); + } } diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/dailyOrder-view.fxml b/src/main/resources/com/bib/essensbestellungsverwaltung/dailyOrder-view.fxml index 69c586f..59e1c27 100644 --- a/src/main/resources/com/bib/essensbestellungsverwaltung/dailyOrder-view.fxml +++ b/src/main/resources/com/bib/essensbestellungsverwaltung/dailyOrder-view.fxml @@ -18,5 +18,6 @@