diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/InvoiceController.java b/src/main/java/com/bib/essensbestellungsverwaltung/InvoiceController.java new file mode 100644 index 0000000..aebd7ba --- /dev/null +++ b/src/main/java/com/bib/essensbestellungsverwaltung/InvoiceController.java @@ -0,0 +1,67 @@ +package com.bib.essensbestellungsverwaltung; + +import javafx.fxml.FXML; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.Spinner; +import javafx.scene.input.MouseEvent; +import javafx.scene.text.Text; + +import java.util.Calendar; + +public class InvoiceController { + @FXML + Text responseText; + @FXML + ChoiceBox monatChoiceBox; + + @FXML + Spinner jahrSpinner; + + @FXML + public void initialize() { + monatChoiceBox.setValue(intToMonth(Calendar.getInstance().get(Calendar.MONTH) + 1)); + jahrSpinner.getValueFactory().setValue(Calendar.getInstance().get(Calendar.YEAR)); + } + + @FXML + void onRechnungErstellenClick(MouseEvent mouseEvent) { + responseText.setText(monatChoiceBox.getValue().toString() + jahrSpinner.getValue()); + // hier rechnung erstellen + } + + private int monthToInt(String month) { + return switch (month) { + case "Januar" -> 1; + case "Februar" -> 2; + case "März" -> 3; + case "April" -> 4; + case "Mai" -> 5; + case "Juni" -> 6; + case "Juli" -> 7; + case "August" -> 8; + case "September" -> 9; + case "Oktober" -> 10; + case "November" -> 11; + case "Dezember" -> 12; + default -> -1; + }; + } + + private String intToMonth(int month) { + return switch (month) { + case 1 -> "Januar"; + case 2 -> "Februar"; + case 3 -> "März"; + case 4 -> "April"; + case 5 -> "Mai"; + case 6 -> "Juni"; + case 7 -> "Juli"; + case 8 -> "August"; + case 9 -> "September"; + case 10 -> "Oktober"; + case 11 -> "November"; + case 12 -> "Dezember"; + default -> ""; + }; + } +} diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/LoginController.java b/src/main/java/com/bib/essensbestellungsverwaltung/LoginController.java index 4325d3b..87b5479 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/LoginController.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/LoginController.java @@ -26,12 +26,8 @@ public class LoginController { String email = tfEmail.getText(); String password = pfPassword.getText(); if(benutzerMap.containsKey(email) && benutzerMap.containsValue(password)){ - FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("menue-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 950,480); - Stage stage = new Stage(); - stage.setTitle("Essen Bestellung im Kindergarten"); - stage.setScene(scene); - stage.show(); + // if user is worker: StartViewApplication.changeScene("workerMenu-view.fxml"); + StartViewApplication.changeScene("parentMenu-view.fxml"); }else { Alert alert = new Alert(Alert.AlertType.ERROR,"Email oder Passwort ist falsch"); alert.showAndWait(); @@ -42,12 +38,6 @@ public class LoginController { } @FXML protected void changeToSignUp() throws IOException { - FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("signUp-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 950,480); - Stage stage = new Stage(); - stage.setTitle("Essen Bestellung im Kindergarten"); - stage.setScene(scene); - stage.show(); - + StartViewApplication.changeScene("signUp-view.fxml"); } } diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java b/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java new file mode 100644 index 0000000..4f21d1b --- /dev/null +++ b/src/main/java/com/bib/essensbestellungsverwaltung/ParentMenuController.java @@ -0,0 +1,77 @@ +package com.bib.essensbestellungsverwaltung; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.control.Button; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.BorderPane; + +import java.io.IOException; + +public class ParentMenuController { + + @FXML + BorderPane contentView; + @FXML + Button essensplanButton; + @FXML + Button kinderButton; + @FXML + Button bestellungButton; + @FXML + Button einstellungenButton; + + @FXML + public void initialize() { + changePage("menue-view.fxml"); + setButtonActive(essensplanButton); + } + + + @FXML + public void onEssensplanClick(MouseEvent mouseEvent) { + setButtonActive(essensplanButton); + changePage("menue-view.fxml"); + } + + @FXML + public void onKinderClick(MouseEvent mouseEvent) { + setButtonActive(kinderButton); + changePage("child-view.fxml"); + } + + @FXML + public void onBestellungClick(MouseEvent mouseEvent) { + setButtonActive(bestellungButton); + changePage("dailyOrder-view.fxml"); + } + + @FXML + public void onEinstellungenClick(MouseEvent mouseEvent) { + setButtonActive(einstellungenButton); + changePage("menue-view.fxml"); + } + + @FXML + public void onAusloggenClick(MouseEvent mouseEvent) throws IOException { + StartViewApplication.changeScene("workerMenu-view.fxml"); + } + + private void changePage(String page) { + try { + Parent root = FXMLLoader.load(getClass().getResource(page)); + contentView.setCenter(root); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private void setButtonActive(Button b) { + einstellungenButton.getStyleClass().remove("active"); + kinderButton.getStyleClass().remove("active"); + bestellungButton.getStyleClass().remove("active"); + essensplanButton.getStyleClass().remove("active"); + b.getStyleClass().add("active"); + } +} diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/SingUpController.java b/src/main/java/com/bib/essensbestellungsverwaltung/SingUpController.java new file mode 100644 index 0000000..f6a5b6f --- /dev/null +++ b/src/main/java/com/bib/essensbestellungsverwaltung/SingUpController.java @@ -0,0 +1,11 @@ +package com.bib.essensbestellungsverwaltung; + +import javafx.event.ActionEvent; + +public class SingUpController { + public void onKontoErstellenBtClick(ActionEvent actionEvent) { + } + + public void onAnmeldenBtClick(ActionEvent actionEvent) { + } +} diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java b/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java index fe03394..ffc7b5a 100644 --- a/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java +++ b/src/main/java/com/bib/essensbestellungsverwaltung/StartViewApplication.java @@ -7,6 +7,7 @@ package com.bib.essensbestellungsverwaltung; import javafx.application.Application; import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; @@ -14,11 +15,12 @@ import java.io.IOException; public class StartViewApplication extends Application { public static Stage primary; + @Override public void start(Stage stage) throws IOException { FXMLLoader fxmlLoader = new FXMLLoader(StartViewApplication.class.getResource("login-view.fxml")); - Scene scene = new Scene(fxmlLoader.load(), 950,480); - //stage = primary; + Scene scene = new Scene(fxmlLoader.load(), 1200, 750); + primary = stage; stage.setTitle("Essen Bestellung im Kindergarten"); stage.setScene(scene); stage.show(); @@ -34,4 +36,9 @@ public class StartViewApplication extends Application { //Database.deleteSample(); launch(); } + + public static void changeScene(String scene) throws IOException { + Parent p = FXMLLoader.load(StartViewApplication.class.getResource(scene)); + primary.getScene().setRoot(p); + } } \ No newline at end of file diff --git a/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java b/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java new file mode 100644 index 0000000..42d7bcb --- /dev/null +++ b/src/main/java/com/bib/essensbestellungsverwaltung/WorkerMenuController.java @@ -0,0 +1,95 @@ +package com.bib.essensbestellungsverwaltung; + +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.control.Button; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.BorderPane; + +import java.io.IOException; + +public class WorkerMenuController { + @FXML + public BorderPane contentView; + + @FXML + Button tagesbestellungButton; + @FXML + Button wochenplanButton; + @FXML + Button monatsabrechnungButton; + @FXML + Button mitarbeiterButton; + @FXML + Button mahlzeitButton; + @FXML + Button einstellungenButton; + + @FXML + public void initialize() { + changePage("menue-view.fxml"); + setButtonActive(tagesbestellungButton); + } + + @FXML + public void onTagesbestellungenClick(MouseEvent mouseEvent) { + changePage("menue-view.fxml"); + setButtonActive(tagesbestellungButton); + } + + @FXML + public void onWochenplanClick(MouseEvent mouseEvent) { + changePage("createFoodplan-view.fxml"); + setButtonActive(wochenplanButton); + } + + @FXML + public void onMonatsabrechnungClick(MouseEvent mouseEvent) { + changePage("invoice-view.fxml"); + setButtonActive(monatsabrechnungButton); + } + + + @FXML + public void onMitarbeiterClick(MouseEvent mouseEvent) { + changePage("createCoworker-view.fxml"); + setButtonActive(mitarbeiterButton); + } + + + @FXML + public void onMahlzeitClick(MouseEvent mouseEvent) { + changePage("createFood-view.fxml"); + setButtonActive(mahlzeitButton); + } + + + public void onEinstellungenClick(MouseEvent mouseEvent) { + setButtonActive(einstellungenButton); + } + + @FXML + public void onAusloggenClick(MouseEvent mouseEvent) throws IOException { + StartViewApplication.changeScene("parentMenu-view.fxml"); + } + + private void changePage(String page) { + try { + Parent root = FXMLLoader.load(getClass().getResource(page)); + contentView.setCenter(root); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private void setButtonActive(Button b) { + tagesbestellungButton.getStyleClass().remove("active"); + monatsabrechnungButton.getStyleClass().remove("active"); + wochenplanButton.getStyleClass().remove("active"); + mahlzeitButton.getStyleClass().remove("active"); + mitarbeiterButton.getStyleClass().remove("active"); + einstellungenButton.getStyleClass().remove("active"); + b.getStyleClass().add("active"); + } +} diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/adminMenue-view.fxml b/src/main/resources/com/bib/essensbestellungsverwaltung/adminMenue-view.fxml deleted file mode 100644 index 1577a9f..0000000 --- a/src/main/resources/com/bib/essensbestellungsverwaltung/adminMenue-view.fxml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
+ +
+ diff --git a/src/main/resources/com/bib/essensbestellungsverwaltung/parentMenue-view.fxml b/src/main/resources/com/bib/essensbestellungsverwaltung/parentMenue-view.fxml deleted file mode 100644 index 71aaf0c..0000000 --- a/src/main/resources/com/bib/essensbestellungsverwaltung/parentMenue-view.fxml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+