diff --git a/src/main/java/id/amigogroup/posterminal/FormUtamaController.java b/src/main/java/id/amigogroup/posterminal/FormUtamaController.java index 8dafd6f..bf2f6a0 100644 --- a/src/main/java/id/amigogroup/posterminal/FormUtamaController.java +++ b/src/main/java/id/amigogroup/posterminal/FormUtamaController.java @@ -5,6 +5,7 @@ import id.amigogroup.posterminal.pencarian.DialogCariNotaTundaController; import id.amigogroup.posterminal.pencarian.DialogCariPelangganController; import id.amigogroup.posterminal.pencarian.DialogCetakUlangNotaController; import id.amigogroup.posterminal.transaksi.DialogKonfirmasiReturController; +import id.amigogroup.posterminal.transaksi.DialogTambahNotaController; import id.amigogroup.posterminal.transaksi.FormTransaksiReturController; import id.amigogroup.posterminal.transaksi.FormTransaksiTunaiController; import id.amigogroup.posterminal.util.Fucout; @@ -93,11 +94,11 @@ public class FormUtamaController implements Initializable { tipeNotaState = Fucout.TIPE_NOTA_TUNAI; }); } - + private void updateSelectedNota(ActionEvent event) { Button buttonSource = (Button) event.getSource(); notaState = navigasi.indexOf(buttonSource); - Fucout.scrollToNode(spNavigasi,buttonSource); + Fucout.scrollToNode(spNavigasi, buttonSource); // if (!tableState.equals(buttonSource.getText().toLowerCase())) { // switch (buttonSource.getText().toLowerCase()) { // case BTN_TUNAI: @@ -248,7 +249,7 @@ public class FormUtamaController implements Initializable { }; listShortcuts.put(kcCariNotaTunda, rnCariNotaTunda); - KeyCombination kcCariCetakUlangNota = new KeyCodeCombination(KeyCode.P,KeyCombination.CONTROL_DOWN); + KeyCombination kcCariCetakUlangNota = new KeyCodeCombination(KeyCode.P, KeyCombination.CONTROL_DOWN); Runnable rnCetakUlangNota = () -> { DialogCetakUlangNotaController dialogCetakUlangNota = new DialogCetakUlangNotaController(); dialogCetakUlangNota.initOwner((Stage) bpMain.getScene().getWindow()); @@ -260,7 +261,7 @@ public class FormUtamaController implements Initializable { KeyCombination kcCheckout = new KeyCodeCombination(KeyCode.F8); Runnable rnCheckout = () -> { - switch(tipeNotaState){ + switch (tipeNotaState) { case Fucout.TIPE_NOTA_TUNAI: setContent(formFactory.getForm(FormConstanta.BAYAR, this)); break; @@ -314,11 +315,18 @@ public class FormUtamaController implements Initializable { @FXML void btnTambahNotaOnAction(ActionEvent event) { - Button buttonBaru = generateButtonNota("10-0220-0000X", - FormConstanta.TRANSAKSI_TUNAI, - Fucout.TIPE_NOTA_TUNAI); - navigasi.add(buttonBaru); - vbNavigasi.getChildren().add(buttonBaru); - jumlahNota++; + DialogTambahNotaController dialogTambahNota = new DialogTambahNotaController(); + dialogTambahNota.initOwner((Stage) bpMain.getScene().getWindow()); + Optional hasilReturn = dialogTambahNota.showAndWait(); + + if (hasilReturn.isPresent() && hasilReturn.get().equals("Tambah")) { + + Button buttonBaru = generateButtonNota("10-0220-0000X", + FormConstanta.TRANSAKSI_TUNAI, + Fucout.TIPE_NOTA_TUNAI); + navigasi.add(buttonBaru); + vbNavigasi.getChildren().add(buttonBaru); + jumlahNota++; + } } } diff --git a/src/main/java/id/amigogroup/posterminal/transaksi/DialogTambahNotaController.java b/src/main/java/id/amigogroup/posterminal/transaksi/DialogTambahNotaController.java new file mode 100644 index 0000000..29e7c87 --- /dev/null +++ b/src/main/java/id/amigogroup/posterminal/transaksi/DialogTambahNotaController.java @@ -0,0 +1,103 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package id.amigogroup.posterminal.transaksi; + +import java.io.IOException; +import java.net.URL; +import java.util.ResourceBundle; +import java.util.logging.Level; +import java.util.logging.Logger; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Parent; +import javafx.scene.control.ButtonType; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Dialog; +import javafx.scene.control.TextField; +import javafx.scene.control.ToggleGroup; +import javafx.scene.layout.AnchorPane; +import javafx.stage.Window; + +/** + * + * @author Josua + */ +public class DialogTambahNotaController extends Dialog implements Initializable { + + @FXML + private AnchorPane apTambahNota; + @FXML + private ToggleGroup tgTipe; + @FXML + private ComboBox cbxPilihNota; + @FXML + private TextField txtFieldAmbilDariCheckout; + + public static final ButtonType btnLanjutkan = new ButtonType("Lanjutkan"); + public static final ButtonType btnBatal = new ButtonType("Batal"); + + + @Override + public void initialize(URL url, ResourceBundle rb) { + cbxPilihNota.getItems().setAll( + "Tunai", + "Bon", + "Bawa Dulu", + "Retur" + ); + } + + public DialogTambahNotaController() { + try { + Window window = getDialogPane().getScene().getWindow(); + window.setOnCloseRequest(event -> this.close()); + + FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/DialogTambahNota.fxml")); + loader.setController(this); +// DialogCariBarangController controller = loader.getController(); + + Parent root = loader.load(); + getDialogPane().setContent(root); + + getDialogPane().getButtonTypes().add(btnBatal); + getDialogPane().getButtonTypes().add(btnLanjutkan); + setResultConverter(buttonType -> { + if (buttonType == btnLanjutkan) { + //radio button mana yang dipilih + //baru, balikin tipe yang dipilih + //dari checkout, balikin isi nomor nota (hanya jika nota ditemukan) + return "Tambah"; + } + return "Batal"; + + }); + setTitle("Tambah Nota"); + } catch (IOException ex) { + Logger.getLogger(DialogKonfirmasiReturController.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @FXML + void rbNotaBaruOnAction(ActionEvent event) { + cbxPilihNota.setDisable(false); + txtFieldAmbilDariCheckout.setDisable(true); + +// Button buttonBaru FormConstanta= generateButtonNota("10-0220-0000X", +// FormConstanta.TRANSAKSI_TUNAI, +// Fucout.TIPE_NOTA_TUNAI); +// navigasi.add(buttonBaru); +// vbNavigasi.getChildren().add(buttonBaru); +// jumlahNota++; + } + + @FXML + void rbAmbilDariCheckoutOnAction(ActionEvent event) { + cbxPilihNota.setDisable(true); + txtFieldAmbilDariCheckout.setDisable(false); + } +} diff --git a/src/main/resources/fxml/DialogTambahNota.fxml b/src/main/resources/fxml/DialogTambahNota.fxml index e7a359a..bd4cdab 100644 --- a/src/main/resources/fxml/DialogTambahNota.fxml +++ b/src/main/resources/fxml/DialogTambahNota.fxml @@ -1,25 +1,26 @@ - + - + -