2023-02-04 21:52:48 +01:00
|
|
|
package com.bib.essensbestellungsverwaltung;
|
|
|
|
|
|
|
|
import javafx.fxml.FXML;
|
|
|
|
import javafx.scene.control.ListView;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class OrderHistoryController {
|
|
|
|
public ListView listView;
|
|
|
|
|
|
|
|
@FXML
|
|
|
|
public void initialize() {
|
|
|
|
List<Child> children = AccountMgr.getAllChildrenFromParentWithId(AccountMgr.currentUser.getId());
|
|
|
|
|
|
|
|
List<String> orders = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Child child : children) {
|
|
|
|
List<String> selections = Database.select("food_selection", new String[] { "childid" }, new String[] { String.valueOf(child.getId()) });
|
|
|
|
for (String selection : selections) {
|
|
|
|
String[] selectionParts = selection.split(":");
|
|
|
|
String foodplanid = selectionParts[2];
|
|
|
|
String foodid = selectionParts[3];
|
|
|
|
String foodName = FoodMgr.getFoodById(Long.parseLong(foodid)).getName();
|
|
|
|
String date = FoodMgr.getFoodPlanById(Long.parseLong(foodplanid)).getDate();
|
|
|
|
orders.add(String.format("%s\t %s \t %s", date, child.getFirstname(), foodName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Collections.sort(orders);
|
2023-02-05 08:38:40 +01:00
|
|
|
Collections.reverse(orders);
|
2023-02-04 21:52:48 +01:00
|
|
|
for(String order : orders){
|
|
|
|
listView.getItems().add(order);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|