/*
 * 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 Controllers.Stock;

import Controllers.Traitement.MyWindow;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;

/**
 *
 * @author Maher Ben Tili
 */
public class BondeSortieDialogConfirmation extends BondeSortieController {
    
    public double Height = MyWindow.myStage.getHeight() ;
    public double Width = MyWindow.myStage.getWidth() ;
    public ObservableList<ListProduitBon> Confdata=FXCollections.observableArrayList();
    public Button bouttonNo = new Button();
    public Button bouttonOK = new Button("Enregistrer");
    public TableView ConfBondEnter = new TableView();
    public Text titre = new Text();
    
    public Text Affecter = new Text();
    public Text Tranporteur = new Text();
    public Text Date = new Text();
    
    public Text titreMSG = new Text();
    public Text detail = new Text();
    public StackPane stackpane = new StackPane();
    
    public Node Setnotification(){
        
        
        Group group = new Group();
        
        AnchorPane Ap = new AnchorPane();
        Ap.setStyle("-fx-background-color: rgba(0,0,0,0.6);");
       
        Pane pa1 = new Pane();
        pa1.setStyle("-fx-background-color:#ffffff; -fx-border-color: #212121; -fx-border-radius: 10 10 0 0; -fx-background-radius: 10 10 0 0;");
        pa1.setPrefHeight(550);
        pa1.setPrefWidth(750);
        
        Pane pa2 = new Pane();
        pa2.setStyle("-fx-background-color:linear-gradient(to bottom, #585858, #333333); -fx-background-radius: 10 10 0 0;");
        pa2.setPrefHeight(30);
        pa2.setPrefWidth(750);
        
        TableColumn TabColBEReference = new TableColumn("Référence");
        TabColBEReference.setMinWidth(125);
        TabColBEReference.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("reference"));
        
        TableColumn TabColBEDesignaton = new TableColumn("Désignation");
        TabColBEDesignaton.setMinWidth(155);
        TabColBEDesignaton.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("designaton"));
        
        TableColumn TabColBEMarque = new TableColumn("Marque");
        TabColBEMarque.setMinWidth(100);
        TabColBEMarque.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("marque"));
        
        TableColumn TabColBECategorie = new TableColumn("Catégorie");
        TabColBECategorie.setMinWidth(100);
        TabColBECategorie.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("categorie"));
        
        TableColumn TabColBETVA = new TableColumn("TVA");
        TabColBETVA.setMinWidth(70);
        TabColBETVA.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("tva"));
        TabColBETVA.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
        
        TableColumn TabColBEPrixTTC = new TableColumn("Prix TTC");
        TabColBEPrixTTC.setMinWidth(70);
        TabColBEPrixTTC.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("prixttc"));
        TabColBEPrixTTC.setStyle( "-fx-alignment: CENTER_RIGHT;");
        
        TableColumn TabColBEQuantite = new TableColumn("Quantité");
        TabColBEQuantite.setMinWidth(70);
        TabColBEQuantite.setCellValueFactory(new PropertyValueFactory<ListProduitBon, String>("quantite"));
        TabColBEQuantite.setStyle( "-fx-alignment: CENTER; -fx-font-weight:bold; -fx-font-size: 10pt;");
        
        
        TableView<ListProduitBon> ConfBonEnter = new TableView<ListProduitBon>();
        
        ConfBonEnter.getColumns().addAll(TabColBEReference, TabColBEDesignaton, TabColBEMarque, TabColBECategorie, TabColBETVA, TabColBEPrixTTC, TabColBEQuantite);
        ConfBonEnter.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
        ConfBonEnter.setLayoutX(12);
        ConfBonEnter.setLayoutY(130);
        ConfBonEnter.setPrefHeight(350);
        ConfBonEnter.setItems(Confdata);
        
        titre.setText("Dialog de confirmation");
        titre.setFont(Font.font("System", FontWeight.BOLD, 14));
        titre.setFill(Color.web("#ffffff"));
        titre.setLayoutX(17);
        titre.setLayoutY(22);
        
        Image imgicon = new Image(getClass().getResourceAsStream("/Public/icon/dialoginform.png"));
        ImageView icon = new ImageView(imgicon);
        icon.setLayoutX(20);
        icon.setLayoutY(60);
        icon.setFitWidth(46);
        icon.setFitHeight(50);
        
        TextFlow DetailMSG = new TextFlow();
        
        DetailMSG.setPrefHeight(120);
        DetailMSG.setPrefWidth(400);
        DetailMSG.setLayoutX(80);
        DetailMSG.setLayoutY(55);
        
        
       
        Text text1 = new Text("Bon de Sortie \n");
        text1.setFont(Font.font("Arial", FontWeight.BOLD, 15));
        text1.setFill(Color.web("#363a38"));
        DetailMSG.getChildren().add(text1);
        
        Text text2 = new Text("Êtes-vous sûr de vouloir enregistrer la bon de sortie");
        text2.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
        text2.setFill(Color.web("#363a38"));
        DetailMSG.getChildren().add(text2);
        
        Text affecter = new Text("Affecté:");
        affecter.setFont(Font.font("Arial", FontWeight.BOLD, 15));
        affecter.setFill(Color.web("#363a38"));
        affecter.setLayoutX(80);
        affecter.setLayoutY(115);
        
        Affecter.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
        Affecter.setFill(Color.web("#363a38"));
        Affecter.setLayoutX(140);
        Affecter.setLayoutY(115);
        
        Text date = new Text("Date:");
        date.setFont(Font.font("Arial", FontWeight.BOLD, 15));
        date.setFill(Color.web("#363a38"));
        date.setLayoutX(280);
        date.setLayoutY(115);
        
        Date.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
        Date.setFill(Color.web("#363a38"));
        Date.setLayoutX(320);
        Date.setLayoutY(115);
        
        Text tranporteur = new Text("Tranporteur:");
        tranporteur.setFont(Font.font("Arial", FontWeight.BOLD, 15));
        tranporteur.setFill(Color.web("#363a38"));
        tranporteur.setLayoutX(500);
        tranporteur.setLayoutY(115);
        
        Tranporteur.setFont(Font.font("Arial", FontWeight.NORMAL, 15));
        Tranporteur.setFill(Color.web("#363a38"));
        Tranporteur.setLayoutX(600);
        Tranporteur.setLayoutY(115);
        
        bouttonOK.setFont(Font.font ("Arial", FontWeight.BOLD, 14));
        bouttonOK.setStyle("-fx-background-color:#4DAE4D; -fx-text-fill: white; -fx-border-radius: 5 5 5 5;");
        Image coffeeImage = new Image(getClass().getResourceAsStream("/Public/icon/iconsave.png"));
        ImageView buttonGraphic = new ImageView();
        buttonGraphic.setImage(coffeeImage);
        bouttonOK.setGraphic(buttonGraphic);
        bouttonOK.setPrefWidth(140);
        bouttonOK.setPrefHeight(35);
        bouttonOK.setLayoutX(600);
        bouttonOK.setLayoutY(500);
        
        
        
        bouttonNo.setText("Annuler");
        bouttonNo.setFont(Font.font ("System", FontWeight.BOLD, 12));
        bouttonNo.setStyle("{-fx-background-color:#EFEFEF; -fx-border-color: #959595; -fx-border-radius: 5 5 5 5;} hover:{-fx-background-color:#E6E6E6;}");
        bouttonNo.setPrefWidth(73);
        bouttonNo.setPrefHeight(30);
        bouttonNo.setLayoutX(500);
        bouttonNo.setLayoutY(503);
        bouttonNo.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
                stackpane.setVisible(false);
            }
        });
        
        group.getChildren().addAll(pa1, pa2, titre, icon, affecter, Affecter, date, Date, tranporteur, Tranporteur, ConfBonEnter, DetailMSG, bouttonOK, bouttonNo);
       
        stackpane.setVisible(true);
        stackpane.getChildren().add(Ap);
        stackpane.getChildren().add(group);
        
        
        
        return stackpane;
            
    }

    
    public void ShowDialg()
    {
        Node node = this.Setnotification();
            
        StackPane Sp = new StackPane();
        
        Sp.setPrefSize((double)MyWindow.PrincipalContentWidth, (double)MyWindow.PrincipalContentHeight);
        Sp.getChildren().add(MyWindow.myParent);
        Sp.getChildren().add(node);
        
        Scene scene = new Scene(Sp);
        
        Stage stage = MyWindow.myStage;
        stage.setScene(scene);
        stage.show();
    }
    
}
