package com.example.depanntout;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class ModifInter2 extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_modif_inter2);
        initialisation();
    }

    private void initialisation() {

        // Get data from Intent
        String date = getIntent().getStringExtra("date");
        String heure = getIntent().getStringExtra("heure");
        String observation = getIntent().getStringExtra("observation");
        int idCli = getIntent().getIntExtra("idCli", -1);

        // Reference TextViews
        EditText etDate = findViewById(R.id.ptModifDate);
        EditText etHeure = findViewById(R.id.ptModifHeure);
        EditText etObservation = findViewById(R.id.ptModifObserv);
        EditText etIdCli = findViewById(R.id.ptModifIdClient);

        // Set data in TextViews
        if (date != null) etDate.setText(date);
        if (heure != null) etHeure.setText(heure);
        if (observation != null) etObservation.setText(observation);
        etIdCli.setText(idCli != -1 ? String.valueOf(idCli) : "");

        // gestion du boutton Quitter
        Button btQuitterInter = (Button) findViewById(R.id.btQuitterInter);
        // Association d'un écouteur d'événement au clic de btQuitter
        btQuitterInter.setOnClickListener(new View.OnClickListener() {
            public void onClick(View arg0) {
                finish();
            }
        });

        Button btnDelete = findViewById(R.id.btnDeleteInter);
        btnDelete.setOnClickListener(v -> supprimerInter());

        Button btnModif = findViewById(R.id.btnModifInter);
        btnModif.setOnClickListener(v -> modifierInter());
    }

    private void  supprimerInter() {

    }

    private void modifierInter() {

    }
}
