You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
728 lines
27 KiB
Java
728 lines
27 KiB
Java
package id.amigogroup.posterminal;
|
|
|
|
import id.amigogroup.posterminal.api.AmigoPosRx;
|
|
import id.amigogroup.posterminal.model.Pelanggan;
|
|
import id.amigogroup.posterminal.pencarian.DialogCariBarangController;
|
|
import id.amigogroup.posterminal.pencarian.DialogCariNotaTundaController;
|
|
import id.amigogroup.posterminal.pencarian.DialogCariPelangganController;
|
|
import id.amigogroup.posterminal.pencarian.DialogCetakNotaController;
|
|
import id.amigogroup.posterminal.pencarian.DialogCetakUlangNotaController;
|
|
import id.amigogroup.posterminal.transaksi.BarangFull;
|
|
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.AlertUtil;
|
|
import id.amigogroup.posterminal.util.Fucout;
|
|
import io.reactivex.Observer;
|
|
import io.reactivex.disposables.Disposable;
|
|
import java.io.IOException;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.URL;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Optional;
|
|
import java.util.ResourceBundle;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
import javafx.application.Platform;
|
|
import javafx.event.ActionEvent;
|
|
import javafx.fxml.FXML;
|
|
import javafx.fxml.FXMLLoader;
|
|
import javafx.fxml.Initializable;
|
|
import javafx.scene.Node;
|
|
import javafx.scene.Parent;
|
|
import javafx.scene.Scene;
|
|
import javafx.scene.control.Alert;
|
|
import javafx.scene.control.Button;
|
|
import javafx.scene.control.Label;
|
|
import javafx.scene.control.ScrollPane;
|
|
import javafx.scene.control.TextField;
|
|
import javafx.scene.image.Image;
|
|
import javafx.scene.input.KeyCode;
|
|
import javafx.scene.input.KeyCodeCombination;
|
|
import javafx.scene.input.KeyCombination;
|
|
import javafx.scene.input.KeyEvent;
|
|
import javafx.scene.layout.BorderPane;
|
|
import javafx.scene.layout.VBox;
|
|
import javafx.stage.Stage;
|
|
import javafx.stage.Window;
|
|
import retrofit2.HttpException;
|
|
|
|
public class FormUtamaController implements Initializable {
|
|
|
|
@FXML
|
|
private BorderPane bpMain;
|
|
@FXML
|
|
private ScrollPane spMainContent;
|
|
@FXML
|
|
private ScrollPane spNavigasi;
|
|
@FXML
|
|
private VBox vbNavigasi;
|
|
@FXML
|
|
private Button btnTambahNota;
|
|
@FXML
|
|
private Label lblNamaLogin;
|
|
@FXML
|
|
private Label lblMemberNonMember;
|
|
@FXML
|
|
private Label lblKodePelanggan;
|
|
@FXML
|
|
private Label lblNamaPelanggan;
|
|
@FXML
|
|
private Label lblTglLahirPelanggan;
|
|
@FXML
|
|
private Label lblNoTelpPelanggan;
|
|
@FXML
|
|
private TextField tfScanMember;
|
|
|
|
private final FormFactory formFactory = new FormFactory();
|
|
|
|
private final List<Button> navigasi = new ArrayList<>();
|
|
private int notaState = -1;
|
|
private String tipeTransaksiState = "";
|
|
private final char NOTA_PREV = 'p';
|
|
private final char NOTA_NEXT = 'n';
|
|
public final NotaContent notaContent = new NotaContent();
|
|
private final AmigoPosRx posRx = new AmigoPosRx();
|
|
|
|
/**
|
|
* Initializes the controller class.
|
|
*/
|
|
@Override
|
|
public void initialize(URL url, ResourceBundle rb) {
|
|
//Kode Sri Sumarmi (i140411), Nur Indah Suciati (00334), Kode Wuryaningsih/RT (010004)
|
|
updateLabelMemberNonMember();
|
|
|
|
if (SystemValue.karyawanLogin != null) {
|
|
lblNamaLogin.setText(Fucout.getTextColon(SystemValue.karyawanLogin.getNama()));
|
|
}
|
|
|
|
initShorcuts();
|
|
}
|
|
|
|
private void updateLabelPelanggan(Pelanggan p) {
|
|
updateLabelMemberNonMember();
|
|
if (Fucout.checkBirthday(p.getTglLahir())) {
|
|
Alert alertUltah = AlertUtil.getAlertUlangTahun(p.getNama());
|
|
alertUltah.initOwner(bpMain.getScene().getWindow());
|
|
alertUltah.show();
|
|
}
|
|
lblKodePelanggan.setText(Fucout.getTextColon(p.getAlias()));
|
|
lblNamaPelanggan.setText(Fucout.getTextColon(p.getNama()));
|
|
lblTglLahirPelanggan.setText(Fucout.getTextColon(Fucout.formatTanggal(p.getTglLahir())));
|
|
lblNoTelpPelanggan.setText(Fucout.getTextColon(
|
|
!p.getTelp().equals("") && !p.getPonsel().equals("")
|
|
? p.getTelp() + System.lineSeparator() + p.getPonsel() : p.getTelp() + p.getPonsel()));
|
|
}
|
|
|
|
private void updateLabelMemberNonMember() {
|
|
if (SystemValue.isMember) {
|
|
lblMemberNonMember.setText("Member");
|
|
} else {
|
|
lblMemberNonMember.setText("Non Member");
|
|
}
|
|
}
|
|
|
|
private void updateSelectedNota(ActionEvent event) {
|
|
Button buttonSource = (Button) event.getSource();
|
|
notaState = navigasi.indexOf(buttonSource);
|
|
Fucout.scrollToNode(spNavigasi, buttonSource);
|
|
|
|
for (Button button : navigasi) {
|
|
if (button.equals(buttonSource)) {
|
|
if (!button.getStyleClass().contains("button-navigasi-transaksi-selected")) {
|
|
button.getStyleClass().add("button-navigasi-transaksi-selected");
|
|
}
|
|
} else {
|
|
if (button.getStyleClass().contains("button-navigasi-transaksi-selected")) {
|
|
button.getStyleClass().remove("button-navigasi-transaksi-selected");
|
|
}
|
|
}
|
|
}
|
|
|
|
// fldScan.requestFocus();
|
|
}
|
|
|
|
private Button generateButtonNota(String noNota, String tipeNota, String tipeTeks, boolean baru) {
|
|
Button button = new Button(tipeTeks + ": " + noNota);
|
|
button.getStyleClass().add("button-navigasi-transaksi");
|
|
button.setMaxWidth(Double.MAX_VALUE);
|
|
button.setOnAction((event) -> {
|
|
setContent(loadNota(noNota, tipeNota, baru));
|
|
tipeTransaksiState = tipeNota;
|
|
updateSelectedNota(event);
|
|
});
|
|
|
|
return button;
|
|
}
|
|
|
|
private Node loadNota(String noNota, String tipe, boolean baru) {
|
|
Node node = null;
|
|
FXMLLoader loader = new FXMLLoader();
|
|
try {
|
|
resetShortcutToDefault();
|
|
switch (tipe) {
|
|
case FormConstanta.TRANSAKSI_TUNAI:
|
|
if (notaContent.nodeTunai != null) {
|
|
node = notaContent.nodeTunai;
|
|
} else {
|
|
loader.setLocation(getClass().getResource("/fxml/FormTransaksiTunai.fxml"));
|
|
node = loader.load();
|
|
notaContent.nodeTunai = node;
|
|
|
|
FormTransaksiTunaiController fttc = loader.getController();
|
|
notaContent.setControllerTunai(fttc);
|
|
fttc.initData(this, noNota, baru);
|
|
}
|
|
break;
|
|
case FormConstanta.TRANSAKSI_RETUR:
|
|
if (notaContent.getNodeRetur() != null) {
|
|
node = notaContent.getNodeRetur();
|
|
} else {
|
|
loader.setLocation(getClass().getResource("/fxml/FormTransaksiRetur.fxml"));
|
|
node = loader.load();
|
|
notaContent.setNodeRetur(node);
|
|
|
|
FormTransaksiReturController ftrc = loader.getController();
|
|
notaContent.setControllerRetur(ftrc);
|
|
ftrc.initData(noNota, baru);
|
|
}
|
|
break;
|
|
|
|
}
|
|
} catch (IOException ex) {
|
|
Logger.getLogger(FormUtamaController.class.getName()).log(Level.SEVERE, null, ex);
|
|
}
|
|
return node;
|
|
}
|
|
|
|
private void loadNota(char operasi) {
|
|
int jumlahNota = navigasi.size();
|
|
switch (operasi) {
|
|
case NOTA_PREV:
|
|
if (notaState == -1) {
|
|
notaState = jumlahNota - 1;
|
|
} else {
|
|
notaState--;
|
|
if (notaState < 0) {
|
|
notaState = jumlahNota - 1;
|
|
}
|
|
}
|
|
break;
|
|
case NOTA_NEXT:
|
|
if (notaState == -1) {
|
|
notaState = 0;
|
|
} else {
|
|
notaState++;
|
|
if (notaState >= jumlahNota) {
|
|
notaState = 0;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
if (notaState >= 0 && notaState < jumlahNota) {
|
|
navigasi.get(notaState).fire();
|
|
}
|
|
}
|
|
|
|
private void openCetakNota() {
|
|
DialogCetakNotaController dialogCetakNotaController = new DialogCetakNotaController();
|
|
dialogCetakNotaController.initOwner(bpMain.getScene().getWindow());
|
|
dialogCetakNotaController.initData(notaContent.controllerTunai.daftarTabelTransaksi,
|
|
notaContent.controllerRetur.daftarTabelRetur);
|
|
Optional<String> result = dialogCetakNotaController.showAndWait();
|
|
}
|
|
|
|
private void resetShortcutToDefault() {
|
|
Map<KeyCombination, Runnable> listShortcuts = new HashMap<>();
|
|
|
|
KeyCombination kcCetakNota = new KeyCodeCombination(KeyCode.F10);
|
|
Runnable rnCetakNota = () -> {
|
|
openCetakNota();
|
|
};
|
|
listShortcuts.put(kcCetakNota, rnCetakNota);
|
|
|
|
KeyCombination kcTundaNota = new KeyCodeCombination(KeyCode.T, KeyCombination.CONTROL_DOWN);
|
|
Runnable rnTundaNota = () -> {
|
|
//do nothing
|
|
};
|
|
listShortcuts.put(kcTundaNota, rnTundaNota);
|
|
|
|
bpMain.getScene().getAccelerators().putAll(listShortcuts);
|
|
}
|
|
|
|
private void initShorcuts() {
|
|
Map<KeyCombination, Runnable> listShortcuts = new HashMap<>();
|
|
|
|
KeyCombination kcPrevNota = new KeyCodeCombination(KeyCode.F1);
|
|
Runnable rnPrevNota = () -> {
|
|
loadNota(NOTA_PREV);
|
|
};
|
|
listShortcuts.put(kcPrevNota, rnPrevNota);
|
|
|
|
KeyCombination kcNextNota = new KeyCodeCombination(KeyCode.F2);
|
|
Runnable rnNextNota = () -> {
|
|
loadNota(NOTA_NEXT);
|
|
};
|
|
listShortcuts.put(kcNextNota, rnNextNota);
|
|
|
|
KeyCombination kcTambah = new KeyCodeCombination(KeyCode.F3);
|
|
Runnable rnTambah = () -> {
|
|
btnTambahNota.fire();
|
|
};
|
|
listShortcuts.put(kcTambah, rnTambah);
|
|
|
|
KeyCombination kcCariBarang = new KeyCodeCombination(KeyCode.F5);
|
|
Runnable rnCariBarang = () -> {
|
|
DialogCariBarangController dialogCariBarang = new DialogCariBarangController();
|
|
dialogCariBarang.initOwner(bpMain.getScene().getWindow());
|
|
|
|
Optional<BarangFull> result = dialogCariBarang.showAndWait();
|
|
|
|
if (result.isPresent()) {
|
|
BarangFull barangFull = result.get();
|
|
switch (tipeTransaksiState) {
|
|
case FormConstanta.TRANSAKSI_TUNAI:
|
|
if (notaContent.getControllerTunai() != null) {
|
|
if (barangFull.getBarang() != null && barangFull.getNoBarang() != null
|
|
&& barangFull.getBarang().getIdGabungan().equals(barangFull.getNoBarang().getIdGabungan())) {
|
|
notaContent.getControllerTunai().addToTable(barangFull.getBarang(), barangFull.getNoBarang());
|
|
} else {
|
|
Alert alert = AlertUtil.getAlertWarning(
|
|
AlertUtil.ERROR_TIDAK_LENGKAP_TITLE,
|
|
"Data Barang yang didapat tidak lengkap sehingga tidak bisa ditambahkan ke nota.");
|
|
alert.initOwner(bpMain.getScene().getWindow());
|
|
alert.show();
|
|
}
|
|
}
|
|
break;
|
|
case FormConstanta.TRANSAKSI_RETUR:
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
listShortcuts.put(kcCariBarang, rnCariBarang);
|
|
|
|
KeyCombination kcCariPelanggan = new KeyCodeCombination(KeyCode.F6);
|
|
Runnable rnCariPelanggan = () -> {
|
|
DialogCariPelangganController dialogCariPelanggan = new DialogCariPelangganController();
|
|
dialogCariPelanggan.initOwner(bpMain.getScene().getWindow());
|
|
|
|
Optional<Pelanggan> result = dialogCariPelanggan.showAndWait();
|
|
if (result.isPresent() && result.get() != null) {
|
|
SystemValue.member = result.get();
|
|
SystemValue.isMember = true;
|
|
updateLabelPelanggan(result.get());
|
|
updateLabelMemberNonMember();
|
|
}
|
|
};
|
|
listShortcuts.put(kcCariPelanggan, rnCariPelanggan);
|
|
|
|
KeyCombination kcCariNotaTunda = new KeyCodeCombination(KeyCode.F7);
|
|
Runnable rnCariNotaTunda = () -> {
|
|
DialogCariNotaTundaController dialogCariNotaTunda = new DialogCariNotaTundaController();
|
|
dialogCariNotaTunda.initOwner(bpMain.getScene().getWindow());
|
|
|
|
Optional<String> result = dialogCariNotaTunda.showAndWait();
|
|
};
|
|
listShortcuts.put(kcCariNotaTunda, rnCariNotaTunda);
|
|
|
|
KeyCombination kcCheckout = new KeyCodeCombination(KeyCode.F8);
|
|
Runnable rnCheckout = () -> {
|
|
switch (tipeTransaksiState) {
|
|
case FormConstanta.TRANSAKSI_TUNAI:
|
|
setContent(formFactory.getForm(FormConstanta.BAYAR, this));
|
|
break;
|
|
case FormConstanta.TRANSAKSI_RETUR:
|
|
DialogKonfirmasiReturController dialogKonfirmasiRetur = new DialogKonfirmasiReturController();
|
|
dialogKonfirmasiRetur.initOwner(bpMain.getScene().getWindow());
|
|
dialogKonfirmasiRetur.showAndWait();
|
|
break;
|
|
}
|
|
};
|
|
listShortcuts.put(kcCheckout, rnCheckout);
|
|
|
|
KeyCombination kcCetakNota = new KeyCodeCombination(KeyCode.F10);
|
|
Runnable rnCetakNota = () -> {
|
|
openCetakNota();
|
|
};
|
|
listShortcuts.put(kcCetakNota, rnCetakNota);
|
|
|
|
KeyCombination kcCariCetakUlangNota = new KeyCodeCombination(KeyCode.P, KeyCombination.CONTROL_DOWN);
|
|
Runnable rnCetakUlangNota = () -> {
|
|
DialogCetakUlangNotaController dialogCetakUlangNota = new DialogCetakUlangNotaController();
|
|
dialogCetakUlangNota.initOwner(bpMain.getScene().getWindow());
|
|
|
|
Optional<String> result = dialogCetakUlangNota.showAndWait();
|
|
};
|
|
listShortcuts.put(kcCariCetakUlangNota, rnCetakUlangNota);
|
|
|
|
KeyCombination kcScanMember = new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN);
|
|
Runnable rnScanMember = () -> {
|
|
tfScanMember.requestFocus();
|
|
};
|
|
listShortcuts.put(kcScanMember, rnScanMember);
|
|
|
|
KeyCombination kcLogout = new KeyCodeCombination(KeyCode.L, KeyCombination.CONTROL_DOWN);
|
|
Runnable rnLogout = () -> {
|
|
try {
|
|
Stage stage = generateNewWindow("/fxml/FormLogin.fxml");
|
|
stage.setResizable(false);
|
|
stage.show();
|
|
|
|
Stage thisStage = (Stage) bpMain.getScene().getWindow();
|
|
thisStage.close();
|
|
} catch (IOException ex) {
|
|
Logger.getLogger(FormUtamaController.class.getName()).log(Level.SEVERE, null, ex);
|
|
}
|
|
};
|
|
listShortcuts.put(kcLogout, rnLogout);
|
|
|
|
Platform.runLater(() -> {
|
|
bpMain.getScene().getAccelerators().putAll(listShortcuts);
|
|
});
|
|
}
|
|
|
|
public void setContent(Node node) {
|
|
try {
|
|
spMainContent.setContent(node);
|
|
} catch (NullPointerException npe) {
|
|
Logger.getLogger(FormUtamaController.class
|
|
.getName()).log(Level.SEVERE, null, npe);
|
|
// AlertGenerate.getAlert(AlertGenerate.FXML_FAIL).show();
|
|
}
|
|
}
|
|
|
|
public Stage generateNewWindow(String url) throws IOException {
|
|
Stage stage = new Stage();
|
|
Parent root;
|
|
root = FXMLLoader.load(getClass().getResource(url));
|
|
Scene scene = new Scene(root);
|
|
stage.setTitle(Fucout.APP_TITLE);
|
|
stage.getIcons().add(new Image(Fucout.APP_ICON));
|
|
stage.setScene(scene);
|
|
|
|
return stage;
|
|
}
|
|
|
|
public Window getWindow() {
|
|
return bpMain.getScene().getWindow();
|
|
}
|
|
|
|
@FXML
|
|
void btnTambahNotaOnAction(ActionEvent event) {
|
|
DialogTambahNotaController dialogTambahNota = new DialogTambahNotaController();
|
|
dialogTambahNota.initOwner(bpMain.getScene().getWindow());
|
|
Optional<String> hasilReturn = dialogTambahNota.showAndWait();
|
|
|
|
if (hasilReturn.isPresent()) {
|
|
if (hasilReturn.get().equals("Baru:Tunai")) {
|
|
removeDuplicateNota(FormConstanta.TRANSAKSI_TUNAI);
|
|
Button buttonBaru = generateButtonNota(Fucout.getNoNotaTemporary(),
|
|
FormConstanta.TRANSAKSI_TUNAI,
|
|
Fucout.TEKS_TIPE_NOTA_TUNAI,
|
|
true);
|
|
navigasi.add(buttonBaru);
|
|
vbNavigasi.getChildren().add(buttonBaru);
|
|
notaContent.setBtnTunai(buttonBaru);
|
|
} else if (hasilReturn.get().equals("Baru:Bon")) {
|
|
removeDuplicateNota(FormConstanta.TRANSAKSI_BON);
|
|
Button buttonBaru = generateButtonNota("B-" + Fucout.getNoNotaTemporary(),
|
|
FormConstanta.TRANSAKSI_BON,
|
|
Fucout.TEKS_TIPE_NOTA_BON,
|
|
true);
|
|
navigasi.add(buttonBaru);
|
|
vbNavigasi.getChildren().add(buttonBaru);
|
|
notaContent.setBtnBon(buttonBaru);
|
|
} else if (hasilReturn.get().equals("Baru:Bawa Dulu")) {
|
|
removeDuplicateNota(FormConstanta.TRANSAKSI_BAWA);
|
|
Button buttonBaru = generateButtonNota("W-" + Fucout.getNoNotaTemporary(),
|
|
FormConstanta.TRANSAKSI_BAWA,
|
|
Fucout.TEKS_TIPE_NOTA_BAWA,
|
|
true);
|
|
navigasi.add(buttonBaru);
|
|
vbNavigasi.getChildren().add(buttonBaru);
|
|
notaContent.setBtnBawa(buttonBaru);
|
|
} else if (hasilReturn.get().equals("Baru:Retur")) {
|
|
removeDuplicateNota(FormConstanta.TRANSAKSI_RETUR);
|
|
Button buttonBaru = generateButtonNota("R-" + Fucout.getNoNotaTemporary(),
|
|
FormConstanta.TRANSAKSI_RETUR,
|
|
Fucout.TEKS_TIPE_NOTA_RETUR,
|
|
true);
|
|
navigasi.add(buttonBaru);
|
|
vbNavigasi.getChildren().add(buttonBaru);
|
|
notaContent.setBtnRetur(buttonBaru);
|
|
} else if (hasilReturn.get().contains("Checkout:")) {
|
|
String noNota = hasilReturn.get().substring(9);
|
|
Button buttonBaru = null;
|
|
switch (noNota.charAt(0)) {
|
|
case Fucout.KODE_NOTA_BON:
|
|
removeDuplicateNota(FormConstanta.TRANSAKSI_BON);
|
|
break;
|
|
case Fucout.KODE_NOTA_BAWA:
|
|
removeDuplicateNota(FormConstanta.TRANSAKSI_BAWA);
|
|
break;
|
|
case Fucout.KODE_NOTA_RETUR:
|
|
removeDuplicateNota(FormConstanta.TRANSAKSI_RETUR);
|
|
|
|
buttonBaru = generateButtonNota(noNota,
|
|
FormConstanta.TRANSAKSI_RETUR,
|
|
Fucout.TEKS_TIPE_NOTA_RETUR,
|
|
false);
|
|
notaContent.setBtnRetur(buttonBaru);
|
|
break;
|
|
default:
|
|
removeDuplicateNota(FormConstanta.TRANSAKSI_TUNAI);
|
|
buttonBaru = generateButtonNota(noNota,
|
|
FormConstanta.TRANSAKSI_TUNAI,
|
|
Fucout.TEKS_TIPE_NOTA_TUNAI,
|
|
false);
|
|
notaContent.setBtnTunai(buttonBaru);
|
|
break;
|
|
}
|
|
|
|
if (buttonBaru != null) {
|
|
navigasi.add(buttonBaru);
|
|
vbNavigasi.getChildren().add(buttonBaru);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void removeDuplicateNota(String tipe) {
|
|
switch (tipe) {
|
|
case FormConstanta.TRANSAKSI_BON:
|
|
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BON)) {
|
|
setContent(null);
|
|
}
|
|
|
|
if (notaContent.getBtnBon() != null) {
|
|
notaContent.controllerBon = null;
|
|
notaContent.nodeBon = null;
|
|
navigasi.remove(notaContent.getBtnBon());
|
|
vbNavigasi.getChildren().remove(notaContent.getBtnBon());
|
|
}
|
|
break;
|
|
case FormConstanta.TRANSAKSI_BAWA:
|
|
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_BAWA)) {
|
|
setContent(null);
|
|
}
|
|
|
|
if (notaContent.getBtnBawa() != null) {
|
|
notaContent.controllerBawa = null;
|
|
notaContent.nodeBawa = null;
|
|
navigasi.remove(notaContent.getBtnBawa());
|
|
vbNavigasi.getChildren().remove(notaContent.getBtnBawa());
|
|
}
|
|
break;
|
|
case FormConstanta.TRANSAKSI_RETUR:
|
|
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_RETUR)) {
|
|
setContent(null);
|
|
}
|
|
|
|
if (notaContent.getBtnRetur() != null) {
|
|
notaContent.controllerRetur = null;
|
|
notaContent.nodeRetur = null;
|
|
navigasi.remove(notaContent.getBtnRetur());
|
|
vbNavigasi.getChildren().remove(notaContent.getBtnRetur());
|
|
}
|
|
break;
|
|
case FormConstanta.TRANSAKSI_TUNAI:
|
|
default:
|
|
if (tipeTransaksiState.equals(FormConstanta.TRANSAKSI_TUNAI)) {
|
|
setContent(null);
|
|
}
|
|
|
|
if (notaContent.getBtnTunai() != null) {
|
|
notaContent.controllerTunai = null;
|
|
notaContent.nodeTunai = null;
|
|
navigasi.remove(notaContent.getBtnTunai());
|
|
vbNavigasi.getChildren().remove(notaContent.getBtnTunai());
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void removeNota(Button btn) {
|
|
setContent(null);
|
|
navigasi.remove(btn);
|
|
vbNavigasi.getChildren().remove(btn);
|
|
}
|
|
|
|
//scan member
|
|
@FXML
|
|
void scanMemberOnPressed(KeyEvent event) {
|
|
if (event.getCode() == KeyCode.ENTER) {
|
|
posRx.getPelangganByKodeMember(tfScanMember.getText()).subscribe(pelangganObserver);
|
|
}
|
|
}
|
|
|
|
Observer<Pelanggan> pelangganObserver = new Observer<Pelanggan>() {
|
|
@Override
|
|
public void onSubscribe(Disposable dspsbl) {
|
|
}
|
|
|
|
@Override
|
|
public void onNext(Pelanggan p) {
|
|
if (p != null) {
|
|
SystemValue.isMember = true;
|
|
SystemValue.member = p;
|
|
|
|
updateLabelPelanggan(p);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onError(Throwable error) {
|
|
if (error instanceof HttpException) {
|
|
switch (((HttpException) error).code()) {
|
|
case HttpURLConnection.HTTP_NOT_FOUND:
|
|
Alert alert = AlertUtil.getAlertError(
|
|
AlertUtil.ERROR_TIDAK_DITEMUKAN_TITLE,
|
|
"Pelanggan dengan kode member tersebut tidak ditemukan.");
|
|
alert.initOwner(bpMain.getScene().getWindow());
|
|
alert.show();
|
|
}
|
|
} else {
|
|
AmigoPosRx.handleGenericError(error, bpMain.getScene().getWindow());
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onComplete() {
|
|
}
|
|
};
|
|
|
|
public class NotaContent {
|
|
|
|
private Button btnTunai;
|
|
private FormTransaksiTunaiController controllerTunai = null;
|
|
private Node nodeTunai = null;
|
|
private Button btnBawa;
|
|
private Object controllerBawa = null;
|
|
private Node nodeBawa = null;
|
|
private Button btnBon;
|
|
private Object controllerBon = null;
|
|
private Node nodeBon = null;
|
|
private Button btnRetur;
|
|
private FormTransaksiReturController controllerRetur = null;
|
|
private Node nodeRetur = null;
|
|
|
|
/**
|
|
* @return the btnTunai
|
|
*/
|
|
public Button getBtnTunai() {
|
|
return btnTunai;
|
|
}
|
|
|
|
/**
|
|
* @param btnTunai the btnTunai to set
|
|
*/
|
|
public void setBtnTunai(Button btnTunai) {
|
|
this.btnTunai = btnTunai;
|
|
}
|
|
|
|
/**
|
|
* @return the controllerTunai
|
|
*/
|
|
public FormTransaksiTunaiController getControllerTunai() {
|
|
return controllerTunai;
|
|
}
|
|
|
|
/**
|
|
* @param controllerTunai the controllerTunai to set
|
|
*/
|
|
public void setControllerTunai(FormTransaksiTunaiController controllerTunai) {
|
|
this.controllerTunai = controllerTunai;
|
|
}
|
|
|
|
/**
|
|
* @return the nodeTunai
|
|
*/
|
|
public Node getNodeTunai() {
|
|
return nodeTunai;
|
|
}
|
|
|
|
/**
|
|
* @param nodeTunai the nodeTunai to set
|
|
*/
|
|
public void setNodeTunai(Node nodeTunai) {
|
|
this.nodeTunai = nodeTunai;
|
|
}
|
|
|
|
/**
|
|
* @return the btnBawa
|
|
*/
|
|
public Button getBtnBawa() {
|
|
return btnBawa;
|
|
}
|
|
|
|
/**
|
|
* @param btnBawa the btnBawa to set
|
|
*/
|
|
public void setBtnBawa(Button btnBawa) {
|
|
this.btnBawa = btnBawa;
|
|
}
|
|
|
|
/**
|
|
* @return the btnBon
|
|
*/
|
|
public Button getBtnBon() {
|
|
return btnBon;
|
|
}
|
|
|
|
/**
|
|
* @param btnBon the btnBon to set
|
|
*/
|
|
public void setBtnBon(Button btnBon) {
|
|
this.btnBon = btnBon;
|
|
}
|
|
|
|
/**
|
|
* @return the btnRetur
|
|
*/
|
|
public Button getBtnRetur() {
|
|
return btnRetur;
|
|
}
|
|
|
|
/**
|
|
* @param btnRetur the btnRetur to set
|
|
*/
|
|
public void setBtnRetur(Button btnRetur) {
|
|
this.btnRetur = btnRetur;
|
|
}
|
|
|
|
/**
|
|
* @return the controllerRetur
|
|
*/
|
|
public FormTransaksiReturController getControllerRetur() {
|
|
return controllerRetur;
|
|
}
|
|
|
|
/**
|
|
* @param controllerRetur the controllerRetur to set
|
|
*/
|
|
public void setControllerRetur(FormTransaksiReturController controllerRetur) {
|
|
this.controllerRetur = controllerRetur;
|
|
}
|
|
|
|
/**
|
|
* @return the nodeRetur
|
|
*/
|
|
public Node getNodeRetur() {
|
|
return nodeRetur;
|
|
}
|
|
|
|
/**
|
|
* @param nodeRetur the nodeRetur to set
|
|
*/
|
|
public void setNodeRetur(Node nodeRetur) {
|
|
this.nodeRetur = nodeRetur;
|
|
}
|
|
|
|
}
|
|
}
|