diff --git a/src/main/java/com/jFxKasse/controller/MainWindowController.java b/src/main/java/com/jFxKasse/controller/MainWindowController.java index 5f31e91..4f5a7b7 100644 --- a/src/main/java/com/jFxKasse/controller/MainWindowController.java +++ b/src/main/java/com/jFxKasse/controller/MainWindowController.java @@ -340,6 +340,9 @@ public class MainWindowController { @FXML private CheckBox switchSeparate; + @FXML + private CheckBox switchAutoPrint; + @SuppressWarnings("unused") private Main main; @@ -510,6 +513,7 @@ public class MainWindowController { xmlc.setHeader(tftheader.getText()); xmlc.setFooter(tftfooter.getText()); xmlc.setCategorySplitted(switchSeparate.isSelected()); + xmlc.setAutoPrintBill(switchAutoPrint.isSelected()); try { xmlc.saveSettings(); @@ -519,6 +523,7 @@ public class MainWindowController { // e.printStackTrace(); } fillPrinterSettings(); + updatePrintButtonLabel(); } @FXML @@ -597,7 +602,10 @@ public class MainWindowController { currentJob.createPosNameDBString(), currentJob.createPosValueDBString(), currentJob.createPosCatDBString(), "verbucht", String.valueOf(currentJob.getJobValue())); - pj.printJob(currentJob.getJobnumber(), xmlc, dbc, pc); + // Print immediately if autoPrintBill is enabled + if (xmlc.getAutoPrintBill()) { + pj.printJob(currentJob.getJobnumber(), xmlc, dbc, pc); + } fillTableJobs(); @@ -862,6 +870,19 @@ public class MainWindowController { switchSeparate.setSelected(xmlc.getCategorySplitted()); + switchAutoPrint.setSelected(xmlc.getAutoPrintBill()); + + updatePrintButtonLabel(); + + } + + private void updatePrintButtonLabel() { + if (xmlc.getAutoPrintBill()) { + btnPrintBill.setText("Drucken"); + } + else { + btnPrintBill.setText("Bestellen"); + } } public void fillCategory() { diff --git a/src/main/java/com/jFxKasse/controller/XMLController.java b/src/main/java/com/jFxKasse/controller/XMLController.java index 104ee06..75dbc46 100644 --- a/src/main/java/com/jFxKasse/controller/XMLController.java +++ b/src/main/java/com/jFxKasse/controller/XMLController.java @@ -24,6 +24,8 @@ public class XMLController { private boolean categorySplitted; + private boolean autoPrintBill; + private String filePath = null; private Properties props = null; @@ -52,6 +54,15 @@ public class XMLController { categorySplitted = "false"; } + String autoPrintBill = null; + + if (this.autoPrintBill) { + autoPrintBill = "true"; + } + else { + autoPrintBill = "false"; + } + try { props.setProperty("databasename", this.databaseName); props.setProperty("printername", this.printername); @@ -61,6 +72,7 @@ public class XMLController { props.setProperty("header", this.header); props.setProperty("footer", this.footer); props.setProperty("categorySplitted", categorySplitted); + props.setProperty("autoPrintBill", autoPrintBill); outputStream = new FileOutputStream(filePath); props.storeToXML(outputStream, "jFxKasse settings"); @@ -114,6 +126,18 @@ public class XMLController { this.categorySplitted = false; } + try { + if (props.getProperty("autoPrintBill").equals("true")) { + this.autoPrintBill = true; + } + else { + this.autoPrintBill = false; + } + } + catch (Exception e) { + this.autoPrintBill = false; + } + inputStream.close(); return true; } @@ -133,6 +157,8 @@ public class XMLController { this.categorySplitted = false; + this.autoPrintBill = false; + this.header = "XYZ GmbH"; this.footer = "Vielen Dank für den Einkauf"; } @@ -201,4 +227,12 @@ public class XMLController { this.categorySplitted = categorySplitted; } + public boolean getAutoPrintBill() { + return autoPrintBill; + } + + public void setAutoPrintBill(boolean autoPrintBill) { + this.autoPrintBill = autoPrintBill; + } + } diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index a287248..693704d 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -155,6 +155,11 @@ + + + + +