reprint job
This commit is contained in:
		
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							@ -4,7 +4,7 @@
 | 
			
		||||
	<modelVersion>4.0.0</modelVersion>
 | 
			
		||||
	<groupId>com</groupId>
 | 
			
		||||
	<artifactId>jFxKasse</artifactId>
 | 
			
		||||
	<version>0.1.0 - without Printer</version>
 | 
			
		||||
	<version>0.2.0</version>
 | 
			
		||||
	<name>jFxKasse</name>
 | 
			
		||||
 | 
			
		||||
	<dependencies>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										77
									
								
								src/main/java/com/jFxKasse/application/PrintJob.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								src/main/java/com/jFxKasse/application/PrintJob.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,77 @@
 | 
			
		||||
package com.jFxKasse.application;
 | 
			
		||||
 | 
			
		||||
import com.jFxKasse.controller.DBController;
 | 
			
		||||
import com.jFxKasse.controller.PrinterController;
 | 
			
		||||
import com.jFxKasse.controller.XMLController;
 | 
			
		||||
 | 
			
		||||
import com.jFxKasse.datatypes.PrintDataSimple;
 | 
			
		||||
 | 
			
		||||
import javafx.geometry.Insets;
 | 
			
		||||
import javafx.scene.control.ButtonType;
 | 
			
		||||
import javafx.scene.control.Dialog;
 | 
			
		||||
import javafx.scene.control.Label;
 | 
			
		||||
import javafx.scene.layout.GridPane;
 | 
			
		||||
import javafx.util.Pair;
 | 
			
		||||
 | 
			
		||||
public class PrintJob
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	private TimeDate timedate = new TimeDate();
 | 
			
		||||
 | 
			
		||||
	public void printJob(int jobID, XMLController xmlc, DBController dbc,
 | 
			
		||||
			PrinterController pc)
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		if ((xmlc.getPrintername().equals("Drucker auswählen")
 | 
			
		||||
				|| xmlc.getPrintername() == null)) {
 | 
			
		||||
			// no printer selected
 | 
			
		||||
			System.out.println("Kein Drucker eingestellt!!!");
 | 
			
		||||
 | 
			
		||||
			// creates a dialog
 | 
			
		||||
			Dialog<Pair<String, String>> dialog = new Dialog<>();
 | 
			
		||||
			dialog.setTitle("Kein Drucker");
 | 
			
		||||
			dialog.setHeaderText("Es ist kein Drucker einestellt.\n"
 | 
			
		||||
					+ "In den Einstellungen einen Drucker auswählen.");
 | 
			
		||||
 | 
			
		||||
			dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
 | 
			
		||||
 | 
			
		||||
			GridPane grid = new GridPane();
 | 
			
		||||
			grid.setHgap(10);
 | 
			
		||||
			grid.setVgap(10);
 | 
			
		||||
			grid.setPadding(new Insets(20, 150, 10, 10));
 | 
			
		||||
 | 
			
		||||
			grid.add(new Label("Tipp:\n"
 | 
			
		||||
					+ "Es kann ein virtueller Drucker installiert werden: \n\n"
 | 
			
		||||
					+ "www.cups-pdf.de"), 0, 0);
 | 
			
		||||
 | 
			
		||||
			dialog.getDialogPane().setContent(grid);
 | 
			
		||||
			dialog.setResizable(true);
 | 
			
		||||
			dialog.showAndWait();
 | 
			
		||||
 | 
			
		||||
		} else {
 | 
			
		||||
			// printer selected
 | 
			
		||||
			pc.selectPrinter(xmlc.getPrintername());
 | 
			
		||||
			if (xmlc.getCategorySplitted()) {
 | 
			
		||||
				// split the bills
 | 
			
		||||
 | 
			
		||||
				// TODO
 | 
			
		||||
 | 
			
		||||
			} else {
 | 
			
		||||
				// one single bills
 | 
			
		||||
				PrintDataSimple pds = new PrintDataSimple(xmlc.getLinebreak(),
 | 
			
		||||
						xmlc.getOffsetHeader(), xmlc.getOffsetFooter(),
 | 
			
		||||
						timedate.getSystemTime() + " " + timedate.getSystemDate(),
 | 
			
		||||
						xmlc.getHeader(), xmlc.getFooter());
 | 
			
		||||
 | 
			
		||||
				pds.setData(Integer.toString(jobID), dbc.getTime_Job(jobID),
 | 
			
		||||
						dbc.getQuantity_Job(jobID), dbc.getName_Job(jobID),
 | 
			
		||||
						dbc.getValue_Job(jobID), dbc.getCategory_Job(jobID),
 | 
			
		||||
						dbc.getJobValue_Job(jobID));
 | 
			
		||||
				System.out.println("Printing job ...");
 | 
			
		||||
				pc.printString(pds.getPrintString());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								src/main/java/com/jFxKasse/application/TimeDate.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/main/java/com/jFxKasse/application/TimeDate.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,26 @@
 | 
			
		||||
package com.jFxKasse.application;
 | 
			
		||||
 | 
			
		||||
import java.text.DateFormat;
 | 
			
		||||
import java.text.SimpleDateFormat;
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
public class TimeDate
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public String getSystemTime()
 | 
			
		||||
	{
 | 
			
		||||
		DateFormat dateFormat = new SimpleDateFormat("HH:mm");
 | 
			
		||||
		Date date = new Date();
 | 
			
		||||
		String time = dateFormat.format(date);
 | 
			
		||||
		return time;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getSystemDate()
 | 
			
		||||
	{
 | 
			
		||||
		DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
 | 
			
		||||
		Date date = new Date();
 | 
			
		||||
		String dateStr = dateFormat.format(date);
 | 
			
		||||
		return dateStr;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -2,6 +2,8 @@ package com.jFxKasse.controller;
 | 
			
		||||
 | 
			
		||||
import javafx.fxml.FXML;
 | 
			
		||||
import javafx.geometry.Insets;
 | 
			
		||||
import javafx.scene.control.Alert;
 | 
			
		||||
import javafx.scene.control.Alert.AlertType;
 | 
			
		||||
import javafx.scene.control.Button;
 | 
			
		||||
import javafx.scene.control.ButtonType;
 | 
			
		||||
import javafx.scene.control.Dialog;
 | 
			
		||||
@ -42,6 +44,8 @@ import javafx.scene.layout.AnchorPane;
 | 
			
		||||
import javafx.scene.layout.GridPane;
 | 
			
		||||
import javafx.util.Pair;
 | 
			
		||||
import com.jFxKasse.application.Main;
 | 
			
		||||
import com.jFxKasse.application.PrintJob;
 | 
			
		||||
import com.jFxKasse.application.TimeDate;
 | 
			
		||||
import com.jFxKasse.datatypes.Job;
 | 
			
		||||
import com.jFxKasse.datatypes.tableDataCurrentOrder;
 | 
			
		||||
import com.jFxKasse.datatypes.tableDataJob;
 | 
			
		||||
@ -354,6 +358,10 @@ public class MainWindowController
 | 
			
		||||
 | 
			
		||||
	private PrinterController pc;
 | 
			
		||||
 | 
			
		||||
	private TimeDate timedate = new TimeDate();
 | 
			
		||||
 | 
			
		||||
	private PrintJob pj = new PrintJob();
 | 
			
		||||
 | 
			
		||||
	private int idPositionen = 0;
 | 
			
		||||
 | 
			
		||||
	private String selectedColorName;
 | 
			
		||||
@ -389,8 +397,7 @@ public class MainWindowController
 | 
			
		||||
		// creates a dialog
 | 
			
		||||
		Dialog<Pair<String, String>> dialog = new Dialog<>();
 | 
			
		||||
		dialog.setTitle("Über jFxKasse");
 | 
			
		||||
		dialog.setHeaderText(
 | 
			
		||||
				"Informationen und Lizenzen - Version 0.1 - Without Printer");
 | 
			
		||||
		dialog.setHeaderText("Informationen und Lizenzen - Version 0.2");
 | 
			
		||||
 | 
			
		||||
		dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK);
 | 
			
		||||
 | 
			
		||||
@ -505,7 +512,6 @@ public class MainWindowController
 | 
			
		||||
		titlePaneStats.setVisible(true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	@FXML
 | 
			
		||||
	public void btnSavePrinterAction(ActionEvent event)
 | 
			
		||||
	{
 | 
			
		||||
@ -596,13 +602,6 @@ public class MainWindowController
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@FXML
 | 
			
		||||
	public void btnReprintJobAction(ActionEvent event)
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	@FXML
 | 
			
		||||
	public void btnPrintBillAction(ActionEvent event)
 | 
			
		||||
	{
 | 
			
		||||
@ -627,26 +626,7 @@ public class MainWindowController
 | 
			
		||||
 | 
			
		||||
		System.out.println(currentJob.getJobnumber());
 | 
			
		||||
 | 
			
		||||
		/* TODO */
 | 
			
		||||
 | 
			
		||||
		// pc.searchPrinters();
 | 
			
		||||
 | 
			
		||||
		// pc.selectPrinter("CUPS-PDF");
 | 
			
		||||
		/* TODO */
 | 
			
		||||
 | 
			
		||||
		PrintDataSimple pds = new PrintDataSimple(28, 1, 2,
 | 
			
		||||
				getSystemTime() + " " + getSystemDate(), "Firma GmbH",
 | 
			
		||||
				"Vielen Dank für den Einkauf");
 | 
			
		||||
 | 
			
		||||
		pds.setData(Integer.toString(currentJob.getJobnumber()),
 | 
			
		||||
				dbc.getTime_Job(currentJob.getJobnumber()),
 | 
			
		||||
				dbc.getQuantity_Job(currentJob.getJobnumber()),
 | 
			
		||||
				dbc.getName_Job(currentJob.getJobnumber()),
 | 
			
		||||
				dbc.getValue_Job(currentJob.getJobnumber()),
 | 
			
		||||
				dbc.getCategory_Job(currentJob.getJobnumber()),
 | 
			
		||||
				dbc.getJobValue_Job(currentJob.getJobnumber()));
 | 
			
		||||
 | 
			
		||||
		pc.printString(pds.getPrintString());
 | 
			
		||||
		pj.printJob(currentJob.getJobnumber(), xmlc, dbc, pc);
 | 
			
		||||
 | 
			
		||||
		fillTableJobs();
 | 
			
		||||
 | 
			
		||||
@ -656,11 +636,18 @@ public class MainWindowController
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@FXML
 | 
			
		||||
	public void btnReprintJobAction(ActionEvent event)
 | 
			
		||||
	{
 | 
			
		||||
		System.out.println("reprint job");
 | 
			
		||||
		 pj.printJob((selectedJobId + 1), xmlc, dbc, pc);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	@FXML
 | 
			
		||||
	public void gridButton01Action(ActionEvent event)
 | 
			
		||||
	{
 | 
			
		||||
		handelGridButtons(1);
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@FXML
 | 
			
		||||
@ -871,12 +858,6 @@ public class MainWindowController
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		/*
 | 
			
		||||
		 * cats.add(dbc.getName_Category(1));
 | 
			
		||||
		 * 
 | 
			
		||||
		 * cats.add(dbc.getName_Category(2)); cats.add(dbc.getName_Category(3));
 | 
			
		||||
		 * cats.add(dbc.getName_Category(4));
 | 
			
		||||
		 */
 | 
			
		||||
		cats.add(dbc.getName_Category(5));
 | 
			
		||||
 | 
			
		||||
		catChoise.setItems(cats);
 | 
			
		||||
@ -938,13 +919,13 @@ public class MainWindowController
 | 
			
		||||
		linesSpinner.setValueFactory(valueFactoryLines);
 | 
			
		||||
 | 
			
		||||
		SpinnerValueFactory<Integer> valueFactoryHeader = //
 | 
			
		||||
				new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 99,
 | 
			
		||||
				new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 99,
 | 
			
		||||
						xmlc.getOffsetHeader());
 | 
			
		||||
 | 
			
		||||
		offsetHeaderSpinner.setValueFactory(valueFactoryHeader);
 | 
			
		||||
 | 
			
		||||
		SpinnerValueFactory<Integer> valueFactoryFooter = //
 | 
			
		||||
				new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 99,
 | 
			
		||||
				new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 99,
 | 
			
		||||
						xmlc.getOffsetFooter());
 | 
			
		||||
 | 
			
		||||
		offsetFooterSpinner.setValueFactory(valueFactoryFooter);
 | 
			
		||||
@ -1076,22 +1057,6 @@ public class MainWindowController
 | 
			
		||||
		this.pc = pc;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getSystemTime()
 | 
			
		||||
	{
 | 
			
		||||
		DateFormat dateFormat = new SimpleDateFormat("HH:mm");
 | 
			
		||||
		Date date = new Date();
 | 
			
		||||
		String time = dateFormat.format(date);
 | 
			
		||||
		return time;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getSystemDate()
 | 
			
		||||
	{
 | 
			
		||||
		DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
 | 
			
		||||
		Date date = new Date();
 | 
			
		||||
		String dateStr = dateFormat.format(date);
 | 
			
		||||
		return dateStr;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setDBLabel() throws Exception
 | 
			
		||||
	{
 | 
			
		||||
		if (xmlc.loadSettings() == true) {
 | 
			
		||||
@ -1429,10 +1394,11 @@ public class MainWindowController
 | 
			
		||||
 | 
			
		||||
						if (dbc.getState_Job(selectedJobId + 1).equals("storniert")) {
 | 
			
		||||
							btnCancelJob.setDisable(true);
 | 
			
		||||
							btnReprintJob.setDisable(true);
 | 
			
		||||
						} else {
 | 
			
		||||
							btnCancelJob.setDisable(false);
 | 
			
		||||
							btnReprintJob.setDisable(false);
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
					}
 | 
			
		||||
				});
 | 
			
		||||
 | 
			
		||||
@ -1471,7 +1437,7 @@ public class MainWindowController
 | 
			
		||||
	public void createNewJob()
 | 
			
		||||
	{
 | 
			
		||||
		currentJob = new Job(dbc.getLatestJobNumber_Job() + 1,
 | 
			
		||||
				getSystemTime() + " " + getSystemDate());
 | 
			
		||||
				timedate.getSystemTime() + " " + timedate.getSystemDate());
 | 
			
		||||
		labelJobCounter.setText("Auftragsnummer: "
 | 
			
		||||
				+ String.valueOf(dbc.getLatestJobNumber_Job() + 1));
 | 
			
		||||
	}
 | 
			
		||||
@ -1520,14 +1486,14 @@ public class MainWindowController
 | 
			
		||||
 | 
			
		||||
		labelAllValue.setText("Gesamt: " + str + "€");
 | 
			
		||||
 | 
			
		||||
		titlePaneStats
 | 
			
		||||
				.setText("Statistik - " + getSystemTime() + " " + getSystemDate());
 | 
			
		||||
		titlePaneStats.setText("Statistik - " + timedate.getSystemTime() + " "
 | 
			
		||||
				+ timedate.getSystemDate());
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void updateTimeLabel()
 | 
			
		||||
	{
 | 
			
		||||
		labelTime.setText("Uhrzeit: " + getSystemTime());
 | 
			
		||||
		labelTime.setText("Uhrzeit: " + timedate.getSystemTime());
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -83,13 +83,13 @@ public class PrinterController implements Printable
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param input data as String
 | 
			
		||||
	 */
 | 
			
		||||
	public void printString(String text)
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		PrintService service = selectedPrinter;
 | 
			
		||||
		DocPrintJob job = service.createPrintJob();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user