fix: tagesbestellung locked foodplan
This commit is contained in:
parent
30cc971aa2
commit
f64dc7751f
@ -2,16 +2,19 @@ package com.bib.essensbestellungsverwaltung;
|
|||||||
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.DatePicker;
|
import javafx.scene.control.DatePicker;
|
||||||
import javafx.scene.control.ListView;
|
import javafx.scene.control.ListView;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DailyOrderController {
|
public class DailyOrderController {
|
||||||
public ListView listView;
|
public ListView listView;
|
||||||
public DatePicker datePicker;
|
public DatePicker datePicker;
|
||||||
|
public Button sendButton;
|
||||||
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@ -26,14 +29,48 @@ public class DailyOrderController {
|
|||||||
|
|
||||||
|
|
||||||
private void updatePlan(String date){
|
private void updatePlan(String date){
|
||||||
|
listView.getItems().clear();
|
||||||
System.out.print("Orders from " + date + " : ");
|
System.out.print("Orders from " + date + " : ");
|
||||||
List<String> orders = FoodMgr.getDayOrder(date);
|
List<String> 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);
|
System.out.println(orders);
|
||||||
|
|
||||||
listView.getItems().clear();
|
|
||||||
for(String order : orders){
|
for(String order : orders){
|
||||||
listView.getItems().add(order);
|
listView.getItems().add(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onSendButton(ActionEvent actionEvent) {
|
||||||
|
FoodMgr.getDayOrder(datePicker.getValue().toString());
|
||||||
|
sendButton.setDisable(true);
|
||||||
|
sendButton.setText("Bestellung wurde Gesendet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,6 @@
|
|||||||
</Text>
|
</Text>
|
||||||
<DatePicker fx:id="datePicker" layoutX="88.0" layoutY="142.0" onAction="#onChangeDate" />
|
<DatePicker fx:id="datePicker" layoutX="88.0" layoutY="142.0" onAction="#onChangeDate" />
|
||||||
<Label layoutX="88.0" layoutY="121.0" text="Datum" />
|
<Label layoutX="88.0" layoutY="121.0" text="Datum" />
|
||||||
|
<Button fx:id="sendButton" layoutX="374.0" layoutY="617.0" mnemonicParsing="false" onAction="#onSendButton" text="Bestellung senden" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
Loading…
Reference in New Issue
Block a user