package tcs.javaproject.guitest;

import javafx.collections.FXCollections;
import javafx.collections.ObservableArray;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import tcs.javaproject.database.DatabaseController;

import java.math.BigDecimal;
import java.net.URL;
import java.util.ResourceBundle;

/**
 * Created by Vsmasster on 12.05.15.
 */
public class SettleController implements Initializable {
   @FXML
   TableView tabSettleView;
   @FXML
   TableColumn colWho,colWhom,colAmount;

   private final DatabaseController dbController = LoginWindow.dbController;
   private final ObservableList<BankTransfer> content = FXCollections.observableArrayList();
   private Budget budget;

   public void setBudget(Budget budget){
      this.budget = budget;
   }

   public void fillAllTables(){
      content.addAll(dbController.calculateBankTransfers(budget.getId()));
      tabSettleView.setItems(content);
   }

   @Override
   public void initialize(URL location, ResourceBundle resources) {
      colWho.setCellValueFactory(new PropertyValueFactory<BankTransfer, String>("who"));
      colWhom.setCellValueFactory(new PropertyValueFactory<BankTransfer, String>("whom"));
      colAmount.setCellValueFactory(new PropertyValueFactory<BankTransfer, BigDecimal>("amount"));
   }
}

@@ -72,51 +72,8 @@
 ns;%0A
-import javafx.collections.ObservableArray;%0A
 impo
@@ -110,16 +110,16 @@
 leList;%0A
+
 import j
@@ -169,16 +169,52 @@
 izable;%0A
+import javafx.scene.control.Button;%0A
 import j
@@ -340,16 +340,43 @@
 actory;%0A
+import javafx.stage.Stage;%0A
 import t
@@ -692,16 +692,59 @@
 lAmount;
+%0A   @FXML%0A   Button btnSettle, btnDeciline;
 %0A%0A   pri
@@ -1418,24 +1418,24 @@
 %3E(%22whom%22));%0A
-
       colAmo
@@ -1516,20 +1516,364 @@
 (%22amount%22));
+%0A%0A      btnSettle.setOnAction(event -%3E %7B%0A         dbController.settleUnaccountedPayments(budget.getId());%0A         Stage stage = (Stage) btnSettle.getScene().getWindow();%0A         stage.close();%0A      %7D);%0A%0A      btnDeciline.setOnAction(event-%3E%7B%0A         Stage stage = (Stage)btnDeciline.getScene().getWindow();%0A         stage.close();%0A      %7D);
 %0A   %7D%0A%7D%0A

add buttons handler