package Controllers.Caisse;

import Models.Caisse.CaisseSortieListe;
import java.net.URL;
import java.util.ResourceBundle;
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 javafx.scene.text.Text;

/**
 * FXML Controller class
 * @author Maher Ben Tili
 */
public class CaisseSortiePrintController implements Initializable {
    
    @FXML private Text TextDate; 
    @FXML private Text TextLocal;
    @FXML private Text TextMontant;
    @FXML private Text TextPaiement;
    @FXML private Text TextPage;
    @FXML private Text TextType;
    
    @FXML public TableView<CaisseSortieListe> TableViewCaisseCltSortie ;
    
    @FXML private TableColumn<CaisseSortieListe ,String> TabColIdCaisse;
    @FXML private TableColumn<CaisseSortieListe ,String> TabColType;
    @FXML private TableColumn<CaisseSortieListe ,String> TabColDate;
    @FXML private TableColumn<CaisseSortieListe ,String> TabColMontant;
    @FXML private TableColumn<CaisseSortieListe ,String> TabColChequeClt;
    @FXML private TableColumn<CaisseSortieListe ,String> TabColEspece;
    @FXML private TableColumn<CaisseSortieListe ,String> TabColCarteBancaire;
    
    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        
        TabColIdCaisse.setStyle( "-fx-alignment: CENTER;");TabColIdCaisse.getStyleClass().add("Center");
        TabColIdCaisse.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("IdCaisseClt"));
        
        TabColType.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Type"));
        
        TabColDate.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Date"));
        
        TabColMontant.setStyle( "-fx-alignment: CENTER;");TabColMontant.getStyleClass().add("Center");
        TabColMontant.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Montant"));
        
        TabColChequeClt.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Cheque"));
        
        TabColEspece.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("Espece"));
        
        TabColCarteBancaire.setCellValueFactory(new PropertyValueFactory<CaisseSortieListe, String>("CarteBancaire"));
    }    
    
    
    public void setCaisseSortiePrint(String Date, 
                                String Local, 
                                String Montant, 
                                String Paiement, 
                                String Page, 
                                String Type,
                                ObservableList<CaisseSortieListe> obsListCaisseCltSortie )
    {
        TextDate.setText(Date);
        TextLocal.setText(Local);
        TextMontant.setText(Montant);
        TextPaiement.setText(Paiement);
        TextPage.setText(Page);
        TextType.setText(Type);
        
        TableViewCaisseCltSortie.setItems(obsListCaisseCltSortie);
    }
}
