0% found this document useful (0 votes)
7 views129 pages

Ecole 7

Ecole7

Uploaded by

anonymouszak16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views129 pages

Ecole 7

Ecole7

Uploaded by

anonymouszak16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 129

from PyQt5.

QtWidgets import QWidget, QLabel , QLineEdit, QPushButton, QVBoxLayout, QMessageBox,


QAction, QMainWindow, QStackedWidget, QApplication,QFrame,QComboBox,
QCheckBox,QTextEdit,QFileDialog, QMessageBox,QDateEdit,QScrollArea,QDialog,QTabWidget

from PyQt5 import QtWidgets, QtGui

from PyQt5.QtCore import Qt, QPropertyAnimation , QRect,QDate

from PyQt5.QtGui import QPixmap , QImage

from datetime import date

import sys

import os

import subprocess

import platform

import mysql.connector

import fitz

from mysql.connector import Error

def creer_connexion():

try:

connexion = mysql.connector.connect(host="localhost", user


="root",password="",database="stage")

if connexion.is_connected():

print("connexion reussie")

return connexion

except Error as e :

print(f"Erreur : {e}")

return None

class Login(QMainWindow):

def __init__(self):

super().__init__()
# Configuration de la fenêtre

self.setWindowTitle("Gestion d'Inventaire")

self.setGeometry(0, 0, 1500, 700)

self.setStyleSheet("background-color: #FF00FF;")

# Créer le widget central

self.stacked_widget = QStackedWidget()

self.setCentralWidget(self.stacked_widget)

# Dictionnaire pour stocker les pages

global pages

pages = {}

global history

history = []

# Page de connexion

self.login_page = LoginPage(self)

self.stacked_widget.addWidget(self.login_page)

self.stacked_widget.setCurrentWidget(self.login_page)

class LoginPage(QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent
self.init_ui()

def init_ui(self):

self.setWindowTitle("Page de Connexion")

# Cadre central pour simuler le verre

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(325, 100, 640, 455)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

# Labels et champs d'entrée

self.title = QLabel("Bienvenue sur la gestion d'inventaire", self.form_frame)

self.title.setGeometry(85, 25, 450, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.username_input = QLineEdit(self.form_frame)

self.username_input.setGeometry(85, 100, 250, 40)

self.username_input.setPlaceholderText("Entrez le nom d'utilisateur")

self.password_input = QLineEdit(self.form_frame)

self.password_input.setGeometry(85, 160, 250, 40)

self.password_input.setPlaceholderText("Entrez le mot de passe")

self.password_input.setEchoMode(QLineEdit.Password)

self.resultat_label = QLabel("", self.form_frame)


self.resultat_label.setGeometry(85, 280, 250, 40)

self.resultat_label.setStyleSheet("color: red;")

# Bouton de connexion

self.login_button = QPushButton("Se connecter", self.form_frame)

self.login_button.setGeometry(210, 350, 120, 40)

self.login_button.clicked.connect(self.authenticate)

def authenticate(self):

username = self.username_input.text()

password = self.password_input.text()

connexion = creer_connexion()

if connexion :

curseur = connexion.cursor()

curseur.execute("SELECT * FROM user WHERE username = %s AND password = %s",


(username,password))

resultat = curseur.fetchone()

connexion.close()

if resultat:

if 'accueil' not in pages :

self.parent.accueil_page= Accueil(self.parent)

self.parent.stacked_widget.addWidget(self.parent.accueil_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.accueil_page)

else:

QMessageBox.warning(self, "Erreur", "Nom d'utilisateur ou mot de passe incorrect")

else:

QMessageBox.warning(self, "Erreur", "impossible de se connecter a la base de données")

class Accueil(QMainWindow):
def __init__(self,parent):

super().__init__()

self.parent = parent

self.init_ui()

def init_ui(self):

layout = QVBoxLayout(self)

label = QLabel("Bienvenue dans l'accueil")

layout.addWidget(label)

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

#panneau lateral

self.side_menu = QFrame(self)

self.side_menu.setGeometry(0,0,0,self.height())

self.side_menu.setStyleSheet("background-color: #F9009F;border-radius: 15px;")

#bouton menu panneau lateral


self.enregistrement = QPushButton("Enregistrement", self.side_menu)

self.enregistrement.setStyleSheet("background-color: #FB00BF;")

self.enregistrement.setGeometry(30,80,150,75)

self.enregistrement.clicked.connect(self.show_enregistrement_page)

self.stagiaire = QPushButton("Stagiaire", self.side_menu)

self.stagiaire.setStyleSheet("background-color: #FB00BF;")

self.stagiaire.setGeometry(30,180,150,75)

self.stagiaire.clicked.connect(self.show_stagiaire_page)

self.suivie = QPushButton("Suivie du Stagiaire", self.side_menu)

self.suivie.setStyleSheet("background-color: #FB00BF; ")

self.suivie.setGeometry(30,280,150,75)

self.suivie.clicked.connect(self.show_suivi_page)

self.validation = QPushButton("Document et Validation", self.side_menu)

self.validation.setStyleSheet("background-color: #FB00BF;")

self.validation.setGeometry(30,380,150,75)

#self.validation.clicked.connect(lambda)

self.historique = QPushButton("Historique", self.side_menu)

self.historique.setStyleSheet("background-color: #FB00BF;")

self.historique.setGeometry(30,480,150,75)

#self.historique.clicked.connect(lambda)
self.deconnection = QPushButton("Deconnection", self.side_menu)

self.deconnection.setStyleSheet("background-color: #FBBBBF;")

self.deconnection.setGeometry(30,640,140,50)

#self.historique.clicked.connect(lambda)

#bouton pour ouvrir/fermer menu

self.toggle_button = QPushButton("|||",self)

self.toggle_button.setGeometry(10,10,80,30)

self.toggle_button.clicked.connect(self.toggle_side_menu)

self.toggle_button.show()

def toggle_side_menu(self):

if self.side_menu.width() == 0:

new_width = 200

else:

new_width = 0

self.animation = QPropertyAnimation(self.side_menu,b"geometry")

self.animation.setDuration(500)

self.animation.setStartValue(QRect(0,0,self.side_menu.width(),self.height()))

self.animation.setEndValue(QRect(0,0,new_width,self.height()))

self.animation.start()

# les fonctions de la page enregistrement

# la fonction de la demande d'enregistrement

def show_enregistrement_page(self):
self.parent.enregistrement_page = EnregistrementPage(self.parent)

self.parent.stacked_widget.addWidget(self.parent.enregistrement_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.enregistrement_page)

def show_stagiaire_page(self):

self.parent.stagiaire_page = stagiaire(self.parent)

self.parent.stacked_widget.addWidget(self.parent.stagiaire_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.stagiaire_page)

def show_suivi_page(self):

self.parent.suivi_page = SuiviPage(self.parent)

self.parent.stacked_widget.addWidget(self.parent.suivi_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.suivi_page)

def show_validation_page(self):

if 'validation' not in pages:

pages['validation'] = ValidationPage()

self.parent.stacked_widget.addWidget(pages['validation'])

self.parent.stacked_widget.setCurrentWidget(pages['validation'])

class EnregistrementPage (QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.init_ui()

def init_ui(self):
self.setWindowTitle("Choisir le type d'enregistrement")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

self.demande_stage_button = QPushButton("Enregistrement d'une demande de stage",


self.form_frame)

self.demande_stage_button.setGeometry(50,50,500,450)

self.demande_stage_button.clicked.connect(self.show_demande_stage_page)

self.stagiaire_button = QPushButton("Enregistrement d'un stagiaire", self.form_frame)

self.stagiaire_button.setGeometry(650,50,500,450)

self.stagiaire_button.clicked.connect(self.show_enregistrement_stagiaire_page)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

def show_demande_stage_page(self):

self.parent.demande_stage_page = demande_stage(self.parent)

self.parent.stacked_widget.addWidget(self.parent.demande_stage_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.demande_stage_page)
def show_enregistrement_stagiaire_page(self):

self.parent.enregistrement_stagiaire_page = enregistrement_stagiaire(self.parent)

self.parent.stacked_widget.addWidget(self.parent.enregistrement_stagiaire_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.enregistrement_stagiaire_page)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.accueil_page)

class demande_stage (QMainWindow):

# enregistrement de demande de stage

def __init__(self,parent):

super().__init__()

self.parent = parent

self.init_ui()

def init_ui(self):

self.setWindowTitle("Type de Demande")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")
self.stage_ecole_button = QPushButton("Stage ecole",self.form_frame)

self.stage_ecole_button.setGeometry(50,120,350,350)

self.stage_ecole_button.clicked.connect(self.show_ecole)

self.immersion_button = QPushButton("Stage en immersion",self.form_frame)

self.immersion_button.setGeometry(425,120,350,350)

self.immersion_button.clicked.connect(self.show_immersion)

self.perfectionnement_button = QPushButton("Stage de perfectionnement",self.form_frame)

self.perfectionnement_button.setGeometry(800,120,350,350)

self.perfectionnement_button.clicked.connect(self.show_renforcement)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.enregistrement_page)

# demande de stage ecole

def show_ecole(self):

self.parent.ecole_page = ecole(self.parent)

self.parent.stacked_widget.addWidget(self.parent.ecole_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.ecole_page)

# demande stage immersion


def show_immersion(self):

self.parent.immersion_page = immersion(self.parent)

self.parent.stacked_widget.addWidget(self.parent.immersion_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.immersion_page)

# demande stage renforcement

def show_renforcement(self):

self.parent.renforcement_page = renforcement(self.parent)

self.parent.stacked_widget.addWidget(self.parent.renforcement_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.renforcement_page)

class enregistrement_stagiaire(QMainWindow):

# enregistrement de stagiaires

def __init__(self,parent):

super().__init__()

self.parent = parent

self.init_ui()

def init_ui(self):

self.setWindowTitle("Type de Demande")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")
self.stagiaire_ecole_button = QPushButton("Stage ecole",self.form_frame)

self.stagiaire_ecole_button.setGeometry(50,120,350,350)

self.stagiaire_ecole_button.clicked.connect(self.enre_stagiaire_ecole)

self.stagiaire_immersion_button = QPushButton("Stage d'immersion",self.form_frame)

self.stagiaire_immersion_button.setGeometry(425,120,350,350)

self.stagiaire_immersion_button.clicked.connect(self.enre_stagiaire_immersion)

self.stagiaire_renforcement_button = QPushButton("Stage de renforcement",self.form_frame)

self.stagiaire_renforcement_button.setGeometry(800,120,350,350)

self.stagiaire_renforcement_button.clicked.connect(self.enre_stagiaire_renforcement)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.enregistrement_page)

# enregistrement stagiaire ecole

def enre_stagiaire_ecole(self):

self.parent.enre_stagiaire_ecole = enregistrement_stagiaire_ecole(self.parent)
self.parent.stacked_widget.addWidget(self.parent.enre_stagiaire_ecole)

self.parent.stacked_widget.setCurrentWidget(self.parent.enre_stagiaire_ecole)

# enregistrement stagiaire immersion

def enre_stagiaire_immersion(self):

self.parent.enre_stagiaire_immersion = enregistrement_stagiaire_immersion(self.parent)

self.parent.stacked_widget.addWidget(self.parent.enre_stagiaire_immersion)

self.parent.stacked_widget.setCurrentWidget(self.parent.enre_stagiaire_immersion)

# enregistrement stagiaire renforcement

def enre_stagiaire_renforcement(self):

self.parent.enre_stagiaire_renforcement = enregistrement_stagiaire_renforcement(self.parent)

self.parent.stacked_widget.addWidget(self.parent.enre_stagiaire_renforcement)

self.parent.stacked_widget.setCurrentWidget(self.parent.enre_stagiaire_renforcement)

# classe d'enregistrement des demandes de stage ecole

class ecole(QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.init_ui()

def init_ui(self):

self.setWindowTitle("Formulaire de demande de stage-ecole")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""
background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE ECOLE) ", self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)

self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setPlaceholderText("nom : ")

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 400, 40)

self.surname_input.setPlaceholderText("prenom : ")

self.daten_label = QLabel("Date de naissance", self.form_frame)

self.daten_label.setGeometry(720, 130, 150, 10)

self.dob_input = QDateEdit(self.form_frame)

self.dob_input.setGeometry(720, 140, 200, 40)

self.dob_input.setCalendarPopup (True)

self.lieu_input = QLineEdit(self.form_frame)

self.lieu_input.setGeometry(970, 190, 220, 40)


self.lieu_input.setPlaceholderText("Lieu de naissance : ")

self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(35, 190, 220, 40)

self.address_input.setPlaceholderText("addresse : ")

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(290, 190, 200, 40)

self.phone_input.setPlaceholderText("numero de telephone : ")

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(510, 190, 350, 40)

self.email_input.setPlaceholderText(" Email : ")

self.infoa = QLabel("PARCOURS ACADEMIQUE :", self.form_frame)

self.infoa.setGeometry(25, 275, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))

self.school_input = QLineEdit(self.form_frame)

self.school_input.setGeometry(35, 320, 320, 40)

self.school_input.setPlaceholderText(" etablissement fréquenté : ")

self.level_input = QLineEdit(self.form_frame)

self.level_input.setGeometry(375, 320, 200, 40)

self.level_input.setPlaceholderText(" diplome preparé : ")

self.major_input = QLineEdit(self.form_frame)

self.major_input.setGeometry(600, 320, 260, 40)


self.major_input.setPlaceholderText(" filière / faculté ")

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(875, 320, 250, 40)

self.contact_input.setPlaceholderText(" Personne a contacter en cas d'urgence ")

self.infodoc = QLabel("DOCUMENTS JOINTS :", self.form_frame)

self.infodoc.setGeometry(25, 380, 350, 30)

self.infodoc.setFont(QtGui.QFont("Arial", 16))

self.cv_button = QPushButton('joindre votre curriculum vitae', self.form_frame)

self.cv_button.setGeometry(35,440,250,125)

self.cv_button.clicked.connect(self.upload_cv)

self.id_checkbox_label = QLabel("photocopie piece d'identité",self.form_frame)

self.id_checkbox_label.setGeometry(300,440,200,30)

self.id_checkbox_yes = QCheckBox("oui",self.form_frame)

self.id_checkbox_yes.setGeometry(600,440,60,40)

self.id_checkbox_no = QCheckBox("non",self.form_frame)

self.id_checkbox_no.setGeometry(700,440,60,40)

self.diplome_checkbox_label = QLabel("admissibilité du diplome",self.form_frame)

self.diplome_checkbox_label.setGeometry(300,500,200,30)

self.diplome_checkbox_yes = QCheckBox("oui",self.form_frame)

self.diplome_checkbox_yes.setGeometry(600,500,60,40)
self.diplome_checkbox_no = QCheckBox("non",self.form_frame)

self.diplome_checkbox_no.setGeometry(700,500,60,40)

self.lettre_checkbox_label = QLabel("lettre de demande de stage",self.form_frame)

self.lettre_checkbox_label.setGeometry(300,560,200,30)

self.lettre_checkbox_yes = QCheckBox("oui",self.form_frame)

self.lettre_checkbox_yes.setGeometry(600,560,60,40)

self.lettre_checkbox_no = QCheckBox("non",self.form_frame)

self.lettre_checkbox_no.setGeometry(700,560,60,40)

self.photo_label = QLabel(self.form_frame)

self.photo_label.setGeometry(940, 30, 180, 150)

self.photo_label.hide()

self.photo_button = QPushButton('joindre photo',self.form_frame)

self.photo_button.setGeometry(940, 30, 180, 150)

self.photo_button.clicked.connect(self.upload_photo)

save_button = QPushButton("Sauvegarder",self.form_frame)

save_button.setGeometry(800,460,150,35)

save_button.clicked.connect(self.save_data)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)
def upload_cv(self):

options = QFileDialog.Options()

file_name , _ = QFileDialog.getOpenFileName(self, "Selectionnez votre CV","","PDF Files (*pdf);; All


Files(*)",options = options)

if file_name:

self.cv_button.setText(file_name)

def upload_letter(self):

options = QFileDialog.Options()

file_name , _ = QFileDialog.getOpenFileName(self, "Selectionnez votre lettre de motivation","","PDF


Files (*pdf);; All Files(*)",options = options)

if file_name:

self.letter_button.setText(file_name)

def upload_photo(self):

options = QFileDialog.Options()

file_name , _ = QFileDialog.getOpenFileName(self, "Selectionnez votre photo","", "Images (*.png


*.jpg *.jpeg);; All Files (*)",options=options)

if file_name :

try:

pixmap = QPixmap(file_name)

if pixmap.isNull():

QMessageBox.Warning(self,"Erreur","Impossible de charger l'image. Veuillez verifier le


format.")

return

pixmap = pixmap.scaled(180,150,Qt.KeepAspectRatio , Qt.SmoothTransformation)

self.photo_label.setPixmap(pixmap)

self.photo_label.show()
self.photo_button.hide()

self.photo_path = file_name

except Exception as e :

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement de l'image : {e}")

def save_data(self):

nom = self.name_input.text()

prenom = self.surname_input.text()

date_naissance = self.dob_input.date().toString("dd/MM/yyyy")

lieu_naissance = self.lieu_input.text()

adresse = self.address_input.text()

telephone = self.phone_input.text()

adresse_email = self.email_input.text()

etablissement = self.school_input.text()

filiere = self.major_input.text()

diplome_prepa = self.level_input.text()

contact_urgent= self.contact_input.text()

cv_file = self.cv_button.text()

piece_identite ="oui" if self.id_checkbox_yes.isChecked() else "non"

admissibilité = "oui" if self.diplome_checkbox_yes else "non"

demande = "oui" if self.lettre_checkbox_yes.isChecked() else "non"

photo_file = getattr(self,'photo_path',None)

if not nom or not prenom or not telephone :

QMessageBox.warning(self,"Erreur","Veuillez remplir les champs obligatoires!!")

else:
connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

requete = """ INSERT INTO stage_ecole (nom,prenom,date_naissance,


lieu_naissance,adresse,telephone,adresse_email,etablissement,filiere,diplome_prepa,contact_urgence,c
v,piece_identite,admissibilite,demande,photo,statut)

VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)

"""

valeurs =
(nom,prenom,date_naissance,lieu_naissance,adresse,telephone,adresse_email,etablissement,filiere,dipl
ome_prepa,contact_urgent,cv_file,piece_identite,admissibilité,demande,photo_file,"en attente")

curseur.execute(requete,valeurs)

connexion.commit()

QMessageBox.information(self,"Soumis",f"Formulaire soumis avec succes pour {nom} !")

# except Error as e:

#QMessageBox.warning(self,"Erreur",f"Erreur lors de l'enregistrement : {e}")

finally:

connexion.close()

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.demande_stage_page)

# classe d'enregistrement des demandes de stage immersion

class immersion(QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.init_ui()
def init_ui(self):

self.setWindowTitle("Formulaire de demande de stage-immersion")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE D'IMMERSION) ", self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)

self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setPlaceholderText("nom : ")

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 400, 40)

self.surname_input.setPlaceholderText("prenom : ")

self.daten_label = QLabel("Date de naissance", self.form_frame)


self.daten_label.setGeometry(720, 130, 150, 10)

self.dob_input = QDateEdit(self.form_frame)

self.dob_input.setGeometry(720, 140, 200, 40)

self.dob_input.setCalendarPopup (True)

self.lieu_input = QLineEdit(self.form_frame)

self.lieu_input.setGeometry(970, 190, 220, 40)

self.lieu_input.setPlaceholderText("Lieu de naissance : ")

self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(35, 190, 220, 40)

self.address_input.setPlaceholderText("addresse : ")

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(290, 190, 200, 40)

self.phone_input.setPlaceholderText("numero de telephone : ")

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(510, 190, 350, 40)

self.email_input.setPlaceholderText(" Email : ")

self.infoa = QLabel("PARCOURS ACADEMIQUE :", self.form_frame)

self.infoa.setGeometry(25, 275, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))

self.school_input = QLineEdit(self.form_frame)

self.school_input.setGeometry(35, 320, 320, 40)


self.school_input.setPlaceholderText(" etablissement fréquenté : ")

self.level_input = QLineEdit(self.form_frame)

self.level_input.setGeometry(375, 320, 200, 40)

self.level_input.setPlaceholderText(" niveau d'etude : ")

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(875, 320, 250, 40)

self.contact_input.setPlaceholderText(" Personne a contacter en cas d'urgence ")

self.infodoc = QLabel("DOCUMENTS :", self.form_frame)

self.infodoc.setGeometry(25, 380, 350, 30)

self.infodoc.setFont(QtGui.QFont("Arial", 16))

self.cv_button = QPushButton('joindre CV', self.form_frame)

self.cv_button.setGeometry(35,440,250,125)

self.cv_button.clicked.connect(self.upload_cv)

self.id_checkbox_label = QLabel("photocopie piece d'identité",self.form_frame)

self.id_checkbox_label.setGeometry(300,440,200,30)

self.id_checkbox_yes = QCheckBox("oui",self.form_frame)

self.id_checkbox_yes.setGeometry(600,440,60,40)

self.id_checkbox_no = QCheckBox("non",self.form_frame)

self.id_checkbox_no.setGeometry(700,440,60,40)

self.attestation_checkbox_label = QLabel("attestation de frequentation",self.form_frame)

self.attestation_checkbox_label.setGeometry(300,500,200,30)

self.attestation_checkbox_yes = QCheckBox("oui",self.form_frame)

self.attestation_checkbox_yes.setGeometry(600,500,60,40)
self.attestation_checkbox_no = QCheckBox("non",self.form_frame)

self.attestation_checkbox_no.setGeometry(700,500,60,40)

self.lettre_checkbox_label = QLabel("lettre de demande de stage",self.form_frame)

self.lettre_checkbox_label.setGeometry(300,560,200,30)

self.lettre_checkbox_yes = QCheckBox("oui",self.form_frame)

self.lettre_checkbox_yes.setGeometry(600,560,60,40)

self.lettre_checkbox_no = QCheckBox("non",self.form_frame)

self.lettre_checkbox_no.setGeometry(700,560,60,40)

self.photo_label = QLabel(self.form_frame)

self.photo_label.setGeometry(940, 30, 180, 150)

self.photo_label.hide()

self.photo_button = QPushButton('joindre photo',self.form_frame)

self.photo_button.setGeometry(940, 30, 180, 150)

self.photo_button.clicked.connect(self.upload_photo)

save_button = QPushButton("Sauvegarder",self.form_frame)

save_button.setGeometry(800,460,150,35)

save_button.clicked.connect(self.save_data)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)
def upload_cv(self):

options = QFileDialog.Options()

file_name , _ = QFileDialog.getOpenFileName(self, "Selectionnez votre CV","","PDF Files (*pdf);; All


Files(*)",options = options)

if file_name:

self.cv_button.setText(file_name)

def upload_letter(self):

options = QFileDialog.Options()

file_name , _ = QFileDialog.getOpenFileName(self, "Selectionnez votre lettre de motivation","","PDF


Files (*pdf);; All Files(*)",options = options)

if file_name:

self.letter_button.setText(file_name)

def upload_photo(self):

options = QFileDialog.Options()

file_name , _ = QFileDialog.getOpenFileName(self, "Selectionnez votre photo","", "Images (*.png


*.jpg *.jpeg);; All Files (*)",options=options)

if file_name :

try:

pixmap = QPixmap(file_name)

if pixmap.isNull():

QMessageBox.Warning(self,"Erreur","Impossible de charger l'image. Veuillez verifier le


format.")

return

pixmap = pixmap.scaled(180,150,Qt.KeepAspectRatio , Qt.SmoothTransformation)


self.photo_label.setPixmap(pixmap)

self.photo_label.show()

self.photo_button.hide()

self.photo_path = file_name

except Exception as e :

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement de l'image : {e}")

def save_data(self):

nom = self.name_input.text()

prenom = self.surname_input.text()

date_naissance = self.dob_input.date().toString("dd/MM/yyyy")

lieu_naissance = self.lieu_input.text()

adresse = self.address_input.text()

telephone = self.phone_input.text()

adresse_email = self.email_input.text()

etablissement = self.school_input.text()

niveau = self.level_input.text()

contact_urgence = self.contact_input.text()

cv_file = self.cv_button.text()

piece_identite ="oui" if self.id_checkbox_yes.isChecked() else "non"

attestation = "oui" if self.attestation_checkbox_yes else "non"

demande = "oui" if self.lettre_checkbox_yes.isChecked() else "non"

photo_file = getattr(self,'photo_path',None)

if not nom or not prenom or not telephone :

QMessageBox.warning(self,"Erreur","Veuillez remplir les champs obligatoires!!")

else:
connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

requete = """ INSERT INTO stage_immersion (nom,prenom,date_naissance,


lieu_naissance,adresse,telephone,adresse_email,etablissement,niveau,contact_urgence,cv,piece_identit
e,attestation,demande,photo,statut)

VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)

"""

valeurs =
(nom,prenom,date_naissance,lieu_naissance,adresse,telephone,adresse_email,etablissement,niveau,co
ntact_urgence,cv_file,piece_identite,attestation,demande,photo_file,"en attente")

curseur.execute(requete,valeurs)

connexion.commit()

QMessageBox.information(self,"Soumis",f"Formulaire soumis avec succes pour {nom} !")

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'enregistrement : {e}")

finally:

connexion.close()

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.demande_stage_page)

# classe d'enregistrement des demandes de stage renforcement

class renforcement(QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent
self.init_ui()

def init_ui(self):

self.setWindowTitle("Formulaire de demande de stage de renforcement")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE DE RENFORCEMENT) ",


self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)

self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setPlaceholderText("nom : ")

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 400, 40)

self.surname_input.setPlaceholderText("prenom : ")
self.daten_label = QLabel("Date de naissance", self.form_frame)

self.daten_label.setGeometry(720, 130, 150, 10)

self.dob_input = QDateEdit(self.form_frame)

self.dob_input.setGeometry(720, 140, 200, 40)

self.dob_input.setCalendarPopup (True)

self.lieu_input = QLineEdit(self.form_frame)

self.lieu_input.setGeometry(970, 190, 220, 40)

self.lieu_input.setPlaceholderText("Lieu de naissance : ")

self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(35, 190, 220, 40)

self.address_input.setPlaceholderText("addresse : ")

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(290, 190, 200, 40)

self.phone_input.setPlaceholderText("numero de telephone : ")

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(510, 190, 350, 40)

self.email_input.setPlaceholderText(" Email : ")

self.infoa = QLabel("PARCOURS ACADEMIQUE :", self.form_frame)

self.infoa.setGeometry(25, 275, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))
self.school_input = QLineEdit(self.form_frame)

self.school_input.setGeometry(35, 320, 320, 40)

self.school_input.setPlaceholderText(" etablissement fréquenté : ")

self.diplome_input = QLineEdit(self.form_frame)

self.diplome_input.setGeometry(375, 320, 200, 40)

self.diplome_input.setPlaceholderText(" diplome : ")

self.major_input = QLineEdit(self.form_frame)

self.major_input.setGeometry(600, 320, 260, 40)

self.major_input.setPlaceholderText(" filière / faculté ")

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(875, 320, 250, 40)

self.contact_input.setPlaceholderText(" Personne a contacter en cas d'urgence ")

self.infodoc = QLabel("DOCUMENTS :", self.form_frame)

self.infodoc.setGeometry(25, 380, 350, 30)

self.infodoc.setFont(QtGui.QFont("Arial", 16))

self.cv_button = QPushButton('joindre CV', self.form_frame)

self.cv_button.setGeometry(35,440,250,125)

self.cv_button.clicked.connect(self.upload_cv)

self.id_checkbox_label = QLabel("photocopie piece d'identité",self.form_frame)

self.id_checkbox_label.setGeometry(300,440,200,30)

self.id_checkbox_yes = QCheckBox("oui",self.form_frame)
self.id_checkbox_yes.setGeometry(600,440,60,40)

self.id_checkbox_no = QCheckBox("non",self.form_frame)

self.id_checkbox_no.setGeometry(700,440,60,40)

self.diplome_checkbox_label = QLabel("diplome",self.form_frame)

self.diplome_checkbox_label.setGeometry(300,500,200,30)

self.diplome_checkbox_yes = QCheckBox("oui",self.form_frame)

self.diplome_checkbox_yes.setGeometry(600,500,60,40)

self.diplome_checkbox_no = QCheckBox("non",self.form_frame)

self.diplome_checkbox_no.setGeometry(700,500,60,40)

self.lettre_checkbox_label = QLabel("lettre de demande de stage",self.form_frame)

self.lettre_checkbox_label.setGeometry(300,560,200,30)

self.lettre_checkbox_yes = QCheckBox("oui",self.form_frame)

self.lettre_checkbox_yes.setGeometry(600,560,60,40)

self.lettre_checkbox_no = QCheckBox("non",self.form_frame)

self.lettre_checkbox_no.setGeometry(700,560,60,40)

self.photo_label = QLabel(self.form_frame)

self.photo_label.setGeometry(940, 30, 180, 150)

self.photo_label.hide()

self.photo_button = QPushButton('joindre photo',self.form_frame)

self.photo_button.setGeometry(940, 30, 180, 150)

self.photo_button.clicked.connect(self.upload_photo)
save_button = QPushButton("Sauvegarder",self.form_frame)

save_button.setGeometry(800,460,150,35)

save_button.clicked.connect(self.save_data)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

def upload_cv(self):

options = QFileDialog.Options()

file_name , _ = QFileDialog.getOpenFileName(self, "Selectionnez votre CV","","PDF Files (*pdf);; All


Files(*)",options = options)

if file_name:

self.cv_button.setText(file_name)

def upload_letter(self):

options = QFileDialog.Options()

file_name , _ = QFileDialog.getOpenFileName(self, "Selectionnez votre lettre de motivation","","PDF


Files (*pdf);; All Files(*)",options = options)

if file_name:

self.letter_button.setText(file_name)
def upload_photo(self):

options = QFileDialog.Options()

file_name , _ = QFileDialog.getOpenFileName(self, "Selectionnez votre photo","", "Images (*.png


*.jpg *.jpeg);; All Files (*)",options=options)

if file_name :

try:

pixmap = QPixmap(file_name)

if pixmap.isNull():

QMessageBox.Warning(self,"Erreur","Impossible de charger l'image. Veuillez verifier le


format.")

return

pixmap = pixmap.scaled(180,150,Qt.KeepAspectRatio , Qt.SmoothTransformation)

self.photo_label.setPixmap(pixmap)

self.photo_label.show()

self.photo_button.hide()

self.photo_path = file_name

except Exception as e :

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement de l'image : {e}")

def save_data(self):

nom = self.name_input.text()

prenom = self.surname_input.text()

date_naissance = self.dob_input.date().toString("dd/MM/yyyy")

lieu_naissance = self.lieu_input.text()

adresse = self.address_input.text()

telephone = self.phone_input.text()

adresse_email = self.email_input.text()

etablissement = self.school_input.text()

diplome = self.diplome_input.text()
filiere = self.major_input.text()

contact_urgence = self.contact_input.text()

cv_file = self.cv_button.text()

piece_identite ="oui" if self.id_checkbox_yes.isChecked() else "non"

diplome_ = "oui" if self.diplome_checkbox_yes else "non"

demande = "oui" if self.lettre_checkbox_yes.isChecked() else "non"

photo_file = getattr(self,'photo_path',None)

if not nom or not prenom or not telephone :

QMessageBox.warning(self,"Erreur","Veuillez remplir les champs obligatoires!!")

else:

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

requete = """ INSERT INTO stage_renforcement (nom,prenom,date_naissance,


lieu_naissance,adresse,telephone,adresse_email,etablissement,diplome,filiere,contact_urgence,cv,piece
_identite,diplome_,demande,photo,statut)

VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)

"""

valeurs =
(nom,prenom,date_naissance,lieu_naissance,adresse,telephone,adresse_email,etablissement,diplome,fi
liere,contact_urgence,cv_file,piece_identite,diplome_,demande,photo_file,"en attente")

curseur.execute(requete,valeurs)

connexion.commit()

QMessageBox.information(self,"Soumis",f"Formulaire soumis avec succes pour {nom} !")

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'enregistrement : {e}")


finally:

connexion.close()

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.demande_stage_page)

# classe d'enregistrement des stagiaires ecole

class enregistrement_stagiaire_ecole (QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.initUI()

self.show_stagiaire_ecole()

def initUI(self):

self.setWindowTitle("Stagiaires - Stage ecole")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")
def show_stagiaire_ecole(self):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT id , nom , prenom , telephone , photo , statut FROM stage_ecole")

stagiaires = curseur.fetchall()

y = 50

for stagiaire in stagiaires:

id , nom , prenom , telephone , photo,statut= stagiaire

self.create_stagiaire_ecole_bloc(id,nom,prenom,telephone , photo,statut,y)

y+=175

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")

finally:

connexion.close()

def create_stagiaire_ecole_bloc(self,id_stagiaire, nom ,prenom,telephone , photo,statut,y):

frame = QFrame(self)

frame.setGeometry(140,y,550,180)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

nom_label = QLabel(f"Nom : {nom}", frame)

nom_label.setGeometry(180,10,300,50)
nom_label.setFont(QtGui.QFont("Arial", 16))

prenom_label = QLabel(f"prenom : {prenom}", frame)

prenom_label.setGeometry(180,40,300,50)

prenom_label.setFont(QtGui.QFont("Arial", 16))

telephone_label = QLabel(f"telephone : {telephone}", frame)

telephone_label.setGeometry(180,70,300,50)

telephone_label.setFont(QtGui.QFont("Arial", 16))

statut_label = QLabel(f"statut : {statut}", frame)

statut_label.setGeometry(180,100,300,50)

statut_label.setFont(QtGui.QFont("Arial", 16))

if photo:

pixmap = QPixmap(photo).scaled(130,130,Qt.KeepAspectRatio,Qt.SmoothTransformation)

photo_label = QLabel(frame)

photo_label.setPixmap(pixmap)

photo_label.setGeometry(10,25,100,100)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

frame.mousePressEvent = lambda event , id = id_stagiaire: self.show_stagiaire_ecole_form(id)

def show_stagiaire_ecole_form(self,id_stagiaire):
self.setWindowTitle("Formulaire complet du stagiaire")

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.stagiaire_ecole_Page = QWidget()

self.stacked.addWidget(self.stagiaire_ecole_Page)

self.form_frame = QtWidgets.QFrame(self.stagiaire_ecole_Page)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT nom,prenom,date_naissance,
lieu_naissance,adresse,telephone,adresse_email,etablissement,filiere,diplome_prepa,contact_urgence,c
v,piece_identite,admissibilite,demande,photo,statut FROM stage_ecole WHERE id = %s",(id_stagiaire,))

stagiaire = curseur.fetchone()

print(id_stagiaire)

print(stagiaire)

if stagiaire:

(nom,prenom,date_naissance,lieu_naissance,adresse,telephone,adresse_email,etablissement,filiere,dipl
ome_prepa,contact_urgence,cv_file,piece_identite,admissibilite,demande,photo,statut) = stagiaire
self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE ECOLE) ", self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)

self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setText(nom)

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 400, 40)

self.surname_input.setText(prenom)

self.daten_label = QLabel("Date de naissance", self.form_frame)

self.daten_label.setGeometry(720, 130, 150, 10)

self.dob_input = QDateEdit(self.form_frame)

self.dob_input.setGeometry(720, 140, 200, 40)

self.dob_input.setCalendarPopup (True)

self.dob_input.setDate(QDate.fromString(date_naissance,"yyyy-MM-dd"))

self.lieu_input = QLineEdit(self.form_frame)
self.lieu_input.setGeometry(970, 190, 220, 40)

self.lieu_input.setText(lieu_naissance)

self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(35, 190, 220, 40)

self.address_input.setText(adresse)

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(290, 190, 200, 40)

self.phone_input.setText(telephone)

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(510, 190, 350, 40)

self.email_input.setText(adresse_email)

self.infoa = QLabel("PARCOURS ACADEMIQUE :", self.form_frame)

self.infoa.setGeometry(25, 275, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))

self.school_input = QLineEdit(self.form_frame)

self.school_input.setGeometry(35, 320, 320, 40)

self.school_input.setText(etablissement)

self.level_input = QLineEdit(self.form_frame)

self.level_input.setGeometry(375, 320, 200, 40)

self.level_input.setText(diplome_prepa)

self.major_input = QLineEdit(self.form_frame)
self.major_input.setGeometry(600, 320, 260, 40)

self.major_input.setText(filiere)

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(875, 320, 250, 40)

self.contact_input.setText(contact_urgence)

self.infodoc = QLabel("DOCUMENTS JOINTS :", self.form_frame)

self.infodoc.setGeometry(25, 380, 350, 30)

self.infodoc.setFont(QtGui.QFont("Arial", 16))

self.cv_file = cv_file

self.cv_button = QPushButton('voir CV', self.form_frame)

self.cv_button.setGeometry(35,440,250,125)

self.cv_button.clicked.connect(self.voir_cv)

self.id_checkbox_label = QLabel("photocopie piece d'identité",self.form_frame)

self.id_checkbox_label.setGeometry(300,440,200,30)

self.id_checkbox_yes = QCheckBox("oui",self.form_frame)

self.id_checkbox_yes.setGeometry(600,440,60,40)

self.id_checkbox_no = QCheckBox("non",self.form_frame)

self.id_checkbox_no.setGeometry(700,440,60,40)

if piece_identite == 'oui':

self.id_checkbox_yes.setChecked(True)

else:

self.id_checkbox_no.setChecked(True)
self.diplome_checkbox_label = QLabel("admissibilité du diplome",self.form_frame)

self.diplome_checkbox_label.setGeometry(300,500,200,30)

self.diplome_checkbox_yes = QCheckBox("oui",self.form_frame)

self.diplome_checkbox_yes.setGeometry(600,500,60,40)

self.diplome_checkbox_no = QCheckBox("non",self.form_frame)

self.diplome_checkbox_no.setGeometry(700,500,60,40)

if admissibilite == 'oui':

self.diplome_checkbox_yes.setChecked(True)

else:

self.diplome_checkbox_no.setChecked(True)

self.lettre_checkbox_label = QLabel("lettre de demande de stage",self.form_frame)

self.lettre_checkbox_label.setGeometry(300,560,200,30)

self.lettre_checkbox_yes = QCheckBox("oui",self.form_frame)

self.lettre_checkbox_yes.setGeometry(600,560,60,40)

self.lettre_checkbox_no = QCheckBox("non",self.form_frame)

self.lettre_checkbox_no.setGeometry(700,560,60,40)

if demande == 'oui':

self.lettre_checkbox_yes.setChecked(True)

else:

self.lettre_checkbox_no.setChecked(True)

self.photo_label = QLabel(self.form_frame)

self.photo_label.setGeometry(940, 30, 180, 150)

photo_pixmap = QPixmap(photo).scaled(180,150,Qt.KeepAspectRatio)
self.photo_view = QLabel(self)

self.photo_view.setPixmap(photo_pixmap)

self.photo_view.setGeometry(940, 30, 180, 150)

self.statut_input = QLineEdit(self.form_frame)

self.statut_input.setGeometry(900, 520, 600, 40)

self.statut_input.setText(statut)

accept_button = QPushButton("Accepter",self.form_frame)

accept_button.setGeometry(800,460,150,35)

accept_button.clicked.connect(lambda event , id = id_stagiaire :self.accept_stagiaire(id))

refus_button = QPushButton("refusé",self.form_frame)

refus_button.setGeometry(800,660,150,35)

refus_button.clicked.connect(lambda event , id = id_stagiaire :self.refus_stagiaire(id))

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'affichage du stagiaire : {e}")

finally:

connexion.close()

def voir_cv(self):

if self.cv_file:
if os.path.exists(self.cv_file):

try:

if os.name == 'nt':

os.startfile(self.cv_file)

elif os.name == 'posix':

subprocess.call(('xdg*open',self.cv_file))

else:

QMessageBox.warning(self, "Erreur","systeme d'exploitation non pris en charge")

except Exception as e :

QMessageBox.warning(self, "Erreur",f"Erreur lors de l'ouverture du CV : {e}")

else:

QMessageBox.warning(self, "Erreur","le fichier n'existe pas")

else:

QMessageBox.warning(self, "Erreur","aucun CV disponible pour ce stagiaire")

def accept_stagiaire(self,id_stagiaire):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("UPDATE stage_ecole SET statut ='accepté' WHERE id = %s", (id_stagiaire,))

connexion.commit()

QMessageBox.information(self,"Succes","le stagiaire a été accepté ")

self.nouveau_stagiaire(id_stagiaire)

finally:

connexion.close()

def refus_stagiaire(self,id_stagiaire):
connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("UPDATE stage_ecole SET statut ='refusé' WHERE id = %s", (id_stagiaire,))

connexion.commit()

QMessageBox.information(self,"Succes","le stagiaire a été refusé ")

finally:

connexion.close()

def nouveau_stagiaire(self,id_stagiaire):

self.setWindowTitle("Formulaire du nouveau stagiaire")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT nom,prenom,date_naissance,
lieu_naissance,adresse,telephone,adresse_email,contact_urgence,cv,photo FROM stage_ecole WHERE
id = %s",(id_stagiaire,))

stagiaire = curseur.fetchone()

if stagiaire:
(nom,prenom,date_naissance,lieu_naissance,adresse,telephone,adresse_email,contact_urgence,cv_file,
photo) = stagiaire

self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE ECOLE) ", self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)

self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setText(nom)

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 400, 40)

self.surname_input.setText(prenom)

self.daten_label = QLabel("Date de naissance", self.form_frame)

self.daten_label.setGeometry(720, 130, 150, 10)

self.dob_input = QDateEdit(self.form_frame)

self.dob_input.setGeometry(720, 140, 200, 40)

self.dob_input.setCalendarPopup (True)

self.dob_input.setDate(QDate.fromString(date_naissance,"yyyy-MM-dd"))
self.lieu_input = QLineEdit(self.form_frame)

self.lieu_input.setGeometry(970, 190, 220, 40)

self.lieu_input.setText(lieu_naissance)

self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(35, 190, 220, 40)

self.address_input.setText(adresse)

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(290, 190, 200, 40)

self.phone_input.setText(telephone)

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(510, 190, 350, 40)

self.email_input.setText(adresse_email)

self.infoa = QLabel("INFORMATION STAGE :", self.form_frame)

self.infoa.setGeometry(25, 275, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(875, 320, 250, 40)

self.contact_input.setText(contact_urgence)

self.photo_ste = photo

if photo:
photo_pixmap = QPixmap(photo).scaled(180,150,Qt.KeepAspectRatio)

self.photo_view = QLabel(self)

self.photo_view.setPixmap(photo_pixmap)

self.photo_view.setGeometry(940, 30, 180, 150)

self.service_input = QLineEdit(self.form_frame)

self.service_input.setGeometry(35, 320, 200, 40)

self.service_input.setPlaceholderText(" Service ")

self.siege_input = QLineEdit(self.form_frame)

self.siege_input.setGeometry(260, 320, 200, 40)

self.siege_input.setPlaceholderText("lieu du Siege ")

self.date_debut_input = QDateEdit(self.form_frame)

self.date_debut_input.setGeometry(485, 320, 220, 40)

self.date_debut_input.setCalendarPopup (True)

self.date_fin_input = QDateEdit(self.form_frame)

self.date_fin_input.setGeometry(730, 320, 220, 40)

self.date_fin_input.setCalendarPopup (True)

self.date_debut_input.dateChanged.connect(self.update_date_fin)

self.photo_label = QLabel(self.form_frame)

self.photo_label.setGeometry(940, 30, 180, 150)

self.statut_input = QLineEdit(self.form_frame)
self.statut_input.setGeometry(975, 320, 300, 40)

self.statut_input.setText("stagiaire")

self.cv_file = cv_file

if cv_file:

self.cv_button = QPushButton('voir CV', self.form_frame)

self.cv_button.setGeometry(35,440,250,125)

self.cv_button.clicked.connect(self.voir_cv)

save_button = QPushButton("Sauvegarder",self.form_frame)

save_button.setGeometry(800,460,150,35)

save_button.clicked.connect(self.save_data)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'affichage du stagiaire : {e}")

finally:

connexion.close()

def update_date_fin(self):

date_debut = self.date_debut_input.date()

date_fin = date_debut.addMonths(3)

self.date_fin_input.setDate(date_fin)

def save_data(self,id_stagiaire):

nom_ste = self.name_input.text()
prenom_ste = self.surname_input.text()

date_naissance_ste = self.dob_input.date().toString("dd/MM/yyyy")

lieu_naissance_ste = self.lieu_input.text()

adresse_ste= self.address_input.text()

telephone_ste = self.phone_input.text()

adresse_email_ste = self.email_input.text()

service_ste = self.service_input.text()

siege_ste = self.siege_input.text

date_debut_ste = self.date_debut_input.date().toString("yyyy-MM-dd")

date_fin_ste = self.date_fin_input.date().toString("yyyy-MM-dd")

cv_ste = self.cv_file

photo_ste = self.photo_ste

statut_ste = self.statut_input.text()

contact_urgence_ste = self.contact_input.text()

if not service_ste or not siege_ste or not date_debut_ste or not date_fin_ste:

QMessageBox.warning(self,"Erreur","Veuillez remplir les champs obligatoires!!")

else:

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

requete = """ INSERT INTO stagiaire_ecole (nom_ste,prenom_ste,date_naissance_ste,


lieu_naissance_ste,adresse_ste,telephone_ste,adresse_email_ste,service_ste,date_debut_ste,date_fin_
ste,contact_urgence__ste,cv_ste,photo_ste,statut_ste)

VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)

"""
valeurs = (nom_ste,prenom_ste,date_naissance_ste,
lieu_naissance_ste,adresse_ste,telephone_ste,adresse_email_ste,service_ste,date_debut_ste,date_fin_
ste,contact_urgence_ste,cv_ste,photo_ste,statut_ste)

curseur.execute(requete,valeurs)

connexion.commit()

QMessageBox.information(self,"Soumis",f"enregistrement du stagiaire {nom_ste} a succes!")

curseur2 = connexion.cursor()

requete2 = "DELETE FROM stage_ecole WHERE id = %s"

curseur2.execute(requete2,(id_stagiaire,))

connexion.commit()

QMessageBox.information(f" le stagiaire {nom_ste} a été supprimé des demandes de stage ")

finally:

connexion.close()

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.enregistrement_page)

# classe d'enregistrement des stagiaires immersion

class enregistrement_stagiaire_immersion (QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.initUI()
self.show_stagiaire_immersion()

def initUI(self):

self.setWindowTitle("Stagiaires - Stage immersion")

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

def show_stagiaire_immersion(self):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT id , nom , prenom , telephone , photo , statut FROM


stage_immersion")

stagiaires = curseur.fetchall()
y = 50

for stagiaire in stagiaires:

id , nom , prenom , telephone , photo,statut= stagiaire

self.create_stagiaire_immersion_bloc(id,nom,prenom,telephone , photo,statut,y)

y+=175

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")

finally:

connexion.close()

def create_stagiaire_immersion_bloc(self,id_stagiaire, nom ,prenom,telephone , photo,statut,y):

frame = QFrame(self)

frame.setGeometry(140,y,550,180)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

nom_label = QLabel(f"Nom : {nom}", frame)

nom_label.setGeometry(180,10,300,50)

nom_label.setFont(QtGui.QFont("Arial", 16))

prenom_label = QLabel(f"prenom : {prenom}", frame)

prenom_label.setGeometry(180,40,300,50)

prenom_label.setFont(QtGui.QFont("Arial", 16))

telephone_label = QLabel(f"telephone : {telephone}", frame)

telephone_label.setGeometry(180,70,300,50)

telephone_label.setFont(QtGui.QFont("Arial", 16))
statut_label = QLabel(f"statut : {statut}", frame)

statut_label.setGeometry(180,100,300,50)

statut_label.setFont(QtGui.QFont("Arial", 16))

if photo:

pixmap = QPixmap(photo).scaled(130,130,Qt.KeepAspectRatio,Qt.SmoothTransformation)

photo_label = QLabel(frame)

photo_label.setPixmap(pixmap)

photo_label.setGeometry(10,25,100,100)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

frame.mousePressEvent = lambda event , id = id_stagiaire: self.show_stagiaire_immersion_form(id)

def show_stagiaire_immersion_form(self,id_stagiaire):

self.setWindowTitle("Formulaire complet du stagiaire")

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.stagiaire_immersion_Page = QWidget()

self.stacked.addWidget(self.stagiaire_immersion_Page)
self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT nom,prenom,date_naissance,
lieu_naissance,adresse,telephone,adresse_email,etablissement,niveau,contact_urgence,cv,piece_identit
e,attestation,demande,photo,statut FROM stage_immersion WHERE id = %s",(id_stagiaire,))

stagiaire = curseur.fetchone()

print(id_stagiaire)

print(stagiaire)

if stagiaire:

(nom,prenom,date_naissance,lieu_naissance,adresse,telephone,adresse_email,etablissement,niveau,co
ntact_urgence,cv_file,piece_identite,attestation,demande,photo_file,statut) = stagiaire

self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE immersion) ", self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)


self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setText(nom)

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 400, 40)

self.surname_input.setText(prenom)

self.daten_label = QLabel("Date de naissance", self.form_frame)

self.daten_label.setGeometry(720, 130, 150, 10)

self.dob_input = QDateEdit(self.form_frame)

self.dob_input.setGeometry(720, 140, 200, 40)

self.dob_input.setCalendarPopup (True)

self.dob_input.setDate(QDate.fromString(date_naissance,"yyyy-MM-dd"))

self.lieu_input = QLineEdit(self.form_frame)

self.lieu_input.setGeometry(970, 190, 220, 40)

self.lieu_input.setText(lieu_naissance)

self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(35, 190, 220, 40)

self.address_input.setText(adresse)

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(290, 190, 200, 40)


self.phone_input.setText(telephone)

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(510, 190, 350, 40)

self.email_input.setText(adresse_email)

self.infoa = QLabel("PARCOURS ACADEMIQUE :", self.form_frame)

self.infoa.setGeometry(25, 275, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))

self.school_input = QLineEdit(self.form_frame)

self.school_input.setGeometry(35, 320, 320, 40)

self.school_input.setText(etablissement)

self.level_input = QLineEdit(self.form_frame)

self.level_input.setGeometry(375, 320, 200, 40)

self.level_input.setText(niveau)

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(875, 320, 250, 40)

self.contact_input.setText(contact_urgence)

self.infodoc = QLabel("DOCUMENTS JOINTS :", self.form_frame)

self.infodoc.setGeometry(25, 380, 350, 30)

self.infodoc.setFont(QtGui.QFont("Arial", 16))

self.cv_file = cv_file

self.cv_button = QPushButton('voir CV', self.form_frame)


self.cv_button.setGeometry(35,440,250,125)

self.cv_button.clicked.connect(self.voir_cv)

self.id_checkbox_label = QLabel("photocopie piece d'identité",self.form_frame)

self.id_checkbox_label.setGeometry(300,440,200,30)

self.id_checkbox_yes = QCheckBox("oui",self.form_frame)

self.id_checkbox_yes.setGeometry(600,440,60,40)

self.id_checkbox_no = QCheckBox("non",self.form_frame)

self.id_checkbox_no.setGeometry(700,440,60,40)

if piece_identite == 'oui':

self.id_checkbox_yes.setChecked(True)

else:

self.id_checkbox_no.setChecked(True)

self.attestation_checkbox_label = QLabel("attestation d'etude",self.form_frame)

self.attestation_checkbox_label.setGeometry(300,500,200,30)

self.attestation_checkbox_yes = QCheckBox("oui",self.form_frame)

self.attestation_checkbox_yes.setGeometry(600,500,60,40)

self.attestation_checkbox_no = QCheckBox("non",self.form_frame)

self.attestation_checkbox_no.setGeometry(700,500,60,40)

if attestation == 'oui':

self.attestation_checkbox_yes.setChecked(True)

else:

self.attestation_checkbox_no.setChecked(True)
self.lettre_checkbox_label = QLabel("lettre de demande de stage",self.form_frame)

self.lettre_checkbox_label.setGeometry(300,560,200,30)

self.lettre_checkbox_yes = QCheckBox("oui",self.form_frame)

self.lettre_checkbox_yes.setGeometry(600,560,60,40)

self.lettre_checkbox_no = QCheckBox("non",self.form_frame)

self.lettre_checkbox_no.setGeometry(700,560,60,40)

if demande == 'oui':

self.lettre_checkbox_yes.setChecked(True)

else:

self.lettre_checkbox_no.setChecked(True)

self.photo_label = QLabel(self.form_frame)

self.photo_label.setGeometry(940, 30, 180, 150)

photo_pixmap = QPixmap(photo_file).scaled(180,150,Qt.KeepAspectRatio)

self.photo_view = QLabel(self)

self.photo_view.setPixmap(photo_pixmap)

self.photo_view.setGeometry(940, 30, 180, 150)

self.statut_input = QLineEdit(self.form_frame)

self.statut_input.setGeometry(900, 520, 600, 40)

self.statut_input.setText(statut)

accept_button = QPushButton("Accepter",self.form_frame)

accept_button.setGeometry(800,460,150,35)

accept_button.clicked.connect(lambda event , id = id_stagiaire :self.accept_stagiaire(id))

refus_button = QPushButton("refusé",self.form_frame)
refus_button.setGeometry(800,660,150,35)

refus_button.clicked.connect(lambda event , id = id_stagiaire :self.refus_stagiaire(id))

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'affichage du stagiaire : {e}")

finally:

connexion.close()

def voir_cv(self):

if self.cv_file:

if os.path.exists(self.cv_file):

try:

if os.name == 'nt':

os.startfile(self.cv_file)

elif os.name == 'posix':

subprocess.call(('xdg*open',self.cv_file))

else:

QMessageBox.warning(self, "Erreur","systeme d'exploitation non pris en charge")

except Exception as e :

QMessageBox.warning(self, "Erreur",f"Erreur lors de l'ouverture du CV : {e}")

else:

QMessageBox.warning(self, "Erreur","le fichier n'existe pas")


else:

QMessageBox.warning(self, "Erreur","aucun CV disponible pour ce stagiaire")

def accept_stagiaire(self,id_stagiaire):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("UPDATE stage_immersion SET statut ='accepté' WHERE id = %s",


(id_stagiaire,))

connexion.commit()

QMessageBox.information(self,"Succes","le stagiaire a été accepté ")

self.nouveau_stagiaire(id_stagiaire)

finally:

connexion.close()

def refus_stagiaire(self,id_stagiaire):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("UPDATE stage_immersion SET statut ='refusé' WHERE id = %s", (id_stagiaire,))

connexion.commit()

QMessageBox.information(self,"Succes","le stagiaire a été refusé ")

finally:

connexion.close()

def nouveau_stagiaire(self,id_stagiaire):
self.setWindowTitle("Formulaire du nouveau stagiaire")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT nom,prenom,date_naissance,
lieu_naissance,adresse,telephone,adresse_email,contact_urgence,cv,photo FROM stage_immersion
WHERE id = %s",(id_stagiaire,))

stagiaire = curseur.fetchone()

if stagiaire:

(nom,prenom,date_naissance,lieu_naissance,adresse,telephone,adresse_email,contact_urgence,cv_file,
photo) = stagiaire

self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE immersion) ", self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)


self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setText(nom)

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 400, 40)

self.surname_input.setText(prenom)

self.daten_label = QLabel("Date de naissance", self.form_frame)

self.daten_label.setGeometry(720, 130, 150, 10)

self.dob_input = QDateEdit(self.form_frame)

self.dob_input.setGeometry(720, 140, 200, 40)

self.dob_input.setCalendarPopup (True)

self.dob_input.setDate(QDate.fromString(date_naissance,"yyyy-MM-dd"))

self.lieu_input = QLineEdit(self.form_frame)

self.lieu_input.setGeometry(970, 190, 220, 40)

self.lieu_input.setText(lieu_naissance)

self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(35, 190, 220, 40)

self.address_input.setText(adresse)

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(290, 190, 200, 40)


self.phone_input.setText(telephone)

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(510, 190, 350, 40)

self.email_input.setText(adresse_email)

self.infoa = QLabel("INFORMATION STAGE :", self.form_frame)

self.infoa.setGeometry(25, 275, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(875, 320, 250, 40)

self.contact_input.setText(contact_urgence)

self.photo_sti = photo

if photo:

photo_pixmap = QPixmap(photo).scaled(180,150,Qt.KeepAspectRatio)

self.photo_view = QLabel(self)

self.photo_view.setPixmap(photo_pixmap)

self.photo_view.setGeometry(940, 30, 180, 150)

self.service_input = QLineEdit(self.form_frame)

self.service_input.setGeometry(35, 320, 200, 40)

self.service_input.setPlaceholderText(" Service ")

self.siege_input = QLineEdit(self.form_frame)

self.siege_input.setGeometry(260, 320, 200, 40)


self.siege_input.setPlaceholderText("lieu du Siege ")

self.date_debut_input = QDateEdit(self.form_frame)

self.date_debut_input.setGeometry(485, 320, 220, 40)

self.date_debut_input.setCalendarPopup (True)

self.date_fin_input = QDateEdit(self.form_frame)

self.date_fin_input.setGeometry(730, 320, 220, 40)

self.date_fin_input.setCalendarPopup (True)

self.date_debut_input.dateChanged.connect(self.update_date_fin)

self.photo_label = QLabel(self.form_frame)

self.photo_label.setGeometry(940, 30, 180, 150)

self.statut_input = QLineEdit(self.form_frame)

self.statut_input.setGeometry(975, 320, 300, 40)

self.statut_input.setText("stagiaire")

self.cv_file = cv_file

if cv_file:

self.cv_button = QPushButton('voir CV', self.form_frame)

self.cv_button.setGeometry(35,440,250,125)

self.cv_button.clicked.connect(self.voir_cv)

save_button = QPushButton("Sauvegarder",self.form_frame)

save_button.setGeometry(800,460,150,35)
save_button.clicked.connect(self.save_data)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'affichage du stagiaire : {e}")

finally:

connexion.close()

def update_date_fin(self):

date_debut = self.date_debut_input.date()

date_fin = date_debut.addMonths(3)

self.date_fin_input.setDate(date_fin)

def save_data(self):

nom_sti = self.name_input.text()

prenom_sti = self.surname_input.text()

date_naissance_sti = self.dob_input.date().toString("dd/MM/yyyy")

lieu_naissance_sti = self.lieu_input.text()

adresse_sti= self.address_input.text()

telephone_sti = self.phone_input.text()

adresse_email_sti = self.email_input.text()

service_sti = self.service_input.text()

siege_sti = self.siege_input.text

date_debut_sti = self.date_debut_input.date().toString("yyyy-MM-dd")

date_fin_sti = self.date_fin_input.date().toString("yyyy-MM-dd")
cv_sti = self.cv_file

photo_sti = self.photo_sti

statut_sti = self.statut_input.text()

contact_urgence_sti = self.contact_input.text()

if not service_sti or not siege_sti or not date_debut_sti or not date_fin_sti:

QMessageBox.warning(self,"Erreur","Veuillez remplir les champs obligatoires!!")

else:

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

requete = """ INSERT INTO stagiaire_immersion (nom_sti,prenom_sti,date_naissance_sti,


lieu_naissance_sti,adresse_sti,telephone_sti,adresse_email_sti,service_sti,date_debut_sti,date_fin_sti,c
ontact_urgence_sti,cv_sti,photo_sti,statut_sti)

VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)

"""

valeurs = (nom_sti,prenom_sti,date_naissance_sti,
lieu_naissance_sti,adresse_sti,telephone_sti,adresse_email_sti,service_sti,date_debut_sti,date_fin_sti,c
ontact_urgence_sti,cv_sti,photo_sti,statut_sti)

curseur.execute(requete,valeurs)

connexion.commit()

QMessageBox.information(self,"Soumis",f"enregistrement du stagiaire {nom_sti} a succes!")

finally:

connexion.close()

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.enregistrement_page)
# classe d'enregistrement des stagiaires renforcement

class enregistrement_stagiaire_renforcement (QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.initUI()

self.show_stagiaire_renforcement()

def initUI(self):

self.setWindowTitle("Stagiaires - Stage renforcement")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

def show_stagiaire_renforcement(self):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()
curseur.execute("SELECT id , nom , prenom , telephone , photo , statut FROM
stage_renforcement")

stagiaires = curseur.fetchall()

y = 50

for stagiaire in stagiaires:

id , nom , prenom , telephone , photo,statut= stagiaire

self.create_stagiaire_renforcement_bloc(id,nom,prenom,telephone , photo,statut,y)

y+=175

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")

finally:

connexion.close()

def create_stagiaire_renforcement_bloc(self,id_stagiaire, nom ,prenom,telephone , photo,statut,y):

frame = QFrame(self)

frame.setGeometry(140,y,550,180)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

nom_label = QLabel(f"Nom : {nom}", frame)

nom_label.setGeometry(180,10,300,50)

nom_label.setFont(QtGui.QFont("Arial", 16))

prenom_label = QLabel(f"prenom : {prenom}", frame)

prenom_label.setGeometry(180,40,300,50)

prenom_label.setFont(QtGui.QFont("Arial", 16))

telephone_label = QLabel(f"telephone : {telephone}", frame)


telephone_label.setGeometry(180,70,300,50)

telephone_label.setFont(QtGui.QFont("Arial", 16))

statut_label = QLabel(f"statut : {statut}", frame)

statut_label.setGeometry(180,100,300,50)

statut_label.setFont(QtGui.QFont("Arial", 16))

if photo:

pixmap = QPixmap(photo).scaled(130,130,Qt.KeepAspectRatio,Qt.SmoothTransformation)

photo_label = QLabel(frame)

photo_label.setPixmap(pixmap)

photo_label.setGeometry(10,25,100,100)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

frame.mousePressEvent = lambda event , id = id_stagiaire:


self.show_stagiaire_renforcement_form(id)

def show_stagiaire_renforcement_form(self,id_stagiaire):

self.setWindowTitle("Formulaire complet du stagiaire")

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)
self.stagiaire_renforcement_Page = QWidget()

self.stacked.addWidget(self.stagiaire_renforcement_Page)

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT nom,prenom,date_naissance,
lieu_naissance,adresse,telephone,adresse_email,etablissement,filiere,diplome,contact_urgence,cv,piece
_identite,diplome_,demande,photo,statut FROM stage_renforcement WHERE id = %s",(id_stagiaire,))

stagiaire = curseur.fetchone()

print(id_stagiaire)

print(stagiaire)

if stagiaire:

(nom,prenom,date_naissance,lieu_naissance,adresse,telephone,adresse_email,etablissement,filiere,dipl
ome,contact_urgence,cv_file,piece_identite,diplome_,demande,photo,statut) = stagiaire

self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE renforcement) ",


self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))
self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)

self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setText(nom)

self.name_input.setEnabled(False)

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 400, 40)

self.surname_input.setText(prenom)

self.surname_input.setEnabled(False)

self.daten_label = QLabel("Date de naissance", self.form_frame)

self.daten_label.setGeometry(720, 130, 150, 10)

self.dob_input = QDateEdit(self.form_frame)

self.dob_input.setGeometry(720, 140, 200, 40)

self.dob_input.setCalendarPopup (True)

self.dob_input.setDate(QDate.fromString(date_naissance,"yyyy-MM-dd"))

self.dob_input.setEnabled(False)

self.lieu_input = QLineEdit(self.form_frame)

self.lieu_input.setGeometry(970, 190, 220, 40)

self.lieu_input.setText(lieu_naissance)

self.lieu_input.setEnabled(False)
self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(35, 190, 220, 40)

self.address_input.setText(adresse)

self.address_input.setEnabled(False)

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(290, 190, 200, 40)

self.phone_input.setText(telephone)

self.phone_input.setEnabled(False)

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(510, 190, 350, 40)

self.email_input.setText(adresse_email)

self.email_input.setEnabled(False)

self.infoa = QLabel("PARCOURS ACADEMIQUE :", self.form_frame)

self.infoa.setGeometry(25, 275, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))

self.school_input = QLineEdit(self.form_frame)

self.school_input.setGeometry(35, 320, 320, 40)

self.school_input.setText(etablissement)

self.school_input.setEnabled(False)

self.diplome_input = QLineEdit(self.form_frame)

self.diplome_input.setGeometry(375, 320, 200, 40)

self.diplome_input.setText(diplome)

self.diplome_input.setEnabled(False)
self.major_input = QLineEdit(self.form_frame)

self.major_input.setGeometry(600, 320, 260, 40)

self.major_input.setText(filiere)

self.major_input.setEnabled(False)

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(875, 320, 250, 40)

self.contact_input.setText(contact_urgence)

self.contact_input.setEnabled(False)

self.infodoc = QLabel("DOCUMENTS JOINTS :", self.form_frame)

self.infodoc.setGeometry(25, 380, 350, 30)

self.infodoc.setFont(QtGui.QFont("Arial", 16))

self.cv_file = cv_file

self.cv_button = QPushButton('voir CV', self.form_frame)

self.cv_button.setGeometry(35,440,250,125)

self.cv_button.clicked.connect(self.voir_cv)

self.id_checkbox_label = QLabel("photocopie piece d'identité",self.form_frame)

self.id_checkbox_label.setGeometry(300,440,200,30)

self.id_checkbox_yes = QCheckBox("oui",self.form_frame)

self.id_checkbox_yes.setGeometry(600,440,60,40)

self.id_checkbox_no = QCheckBox("non",self.form_frame)

self.id_checkbox_no.setGeometry(700,440,60,40)

if piece_identite == 'oui':

self.id_checkbox_yes.setChecked(True)
else:

self.id_checkbox_no.setChecked(True)

self.diplome_checkbox_label = QLabel("admissibilité du diplome",self.form_frame)

self.diplome_checkbox_label.setGeometry(300,500,200,30)

self.diplome_checkbox_yes = QCheckBox("oui",self.form_frame)

self.diplome_checkbox_yes.setGeometry(600,500,60,40)

self.diplome_checkbox_no = QCheckBox("non",self.form_frame)

self.diplome_checkbox_no.setGeometry(700,500,60,40)

if diplome_ == 'oui':

self.diplome_checkbox_yes.setChecked(True)

else:

self.diplome_checkbox_no.setChecked(True)

self.lettre_checkbox_label = QLabel("lettre de demande de stage",self.form_frame)

self.lettre_checkbox_label.setGeometry(300,560,200,30)

self.lettre_checkbox_yes = QCheckBox("oui",self.form_frame)

self.lettre_checkbox_yes.setGeometry(600,560,60,40)

self.lettre_checkbox_no = QCheckBox("non",self.form_frame)

self.lettre_checkbox_no.setGeometry(700,560,60,40)

if demande == 'oui':

self.lettre_checkbox_yes.setChecked(True)

else:

self.lettre_checkbox_no.setChecked(True)

self.photo_label = QLabel(self.form_frame)
self.photo_label.setGeometry(940, 30, 180, 150)

photo_pixmap = QPixmap(photo).scaled(180,150,Qt.KeepAspectRatio)

self.photo_view = QLabel(self)

self.photo_view.setPixmap(photo_pixmap)

self.photo_view.setGeometry(940, 30, 180, 150)

self.statut_input = QLineEdit(self.form_frame)

self.statut_input.setGeometry(900, 520, 600, 40)

self.statut_input.setText(statut)

accept_button = QPushButton("Accepter",self.form_frame)

accept_button.setGeometry(800,460,150,35)

accept_button.clicked.connect(lambda event , id = id_stagiaire :self.accept_stagiaire(id))

refus_button = QPushButton("refusé",self.form_frame)

refus_button.setGeometry(800,660,150,35)

refus_button.clicked.connect(lambda event , id = id_stagiaire :self.refus_stagiaire(id))

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'affichage du stagiaire : {e}")

finally:

connexion.close()
def voir_cv(self):

if self.cv_file:

if os.path.exists(self.cv_file):

try:

if os.name == 'nt':

os.startfile(self.cv_file)

elif os.name == 'posix':

subprocess.call(('xdg*open',self.cv_file))

else:

QMessageBox.warning(self, "Erreur","systeme d'exploitation non pris en charge")

except Exception as e :

QMessageBox.warning(self, "Erreur",f"Erreur lors de l'ouverture du CV : {e}")

else:

QMessageBox.warning(self, "Erreur","le fichier n'existe pas")

else:

QMessageBox.warning(self, "Erreur","aucun CV disponible pour ce stagiaire")

def accept_stagiaire(self,id_stagiaire):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("UPDATE stage_renforcement SET statut ='accepté' WHERE id = %s",


(id_stagiaire,))

connexion.commit()
QMessageBox.information(self,"Succes","le stagiaire a été accepté ")

self.nouveau_stagiaire(id_stagiaire)

finally:

connexion.close()

def refus_stagiaire(self,id_stagiaire):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("UPDATE stage_renforcement SET statut ='refusé' WHERE id = %s",


(id_stagiaire,))

connexion.commit()

QMessageBox.information(self,"Succes","le stagiaire a été refusé ")

finally:

connexion.close()

def nouveau_stagiaire(self,id_stagiaire):

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

connexion = creer_connexion()
if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT nom,prenom,date_naissance,
lieu_naissance,adresse,telephone,adresse_email,contact_urgence,cv,photo FROM stage_renforcement
WHERE id = %s",(id_stagiaire,))

stagiaire = curseur.fetchone()

if stagiaire:

(nom,prenom,date_naissance,lieu_naissance,adresse,telephone,adresse_email,contact_urgence,cv_file,
photo) = stagiaire

self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE renforcement) ",


self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)

self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setText(nom)

self.name_input.setEnabled(False)

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 400, 40)


self.surname_input.setText(prenom)

self.surname_input.setEnabled(False)

self.daten_label = QLabel("Date de naissance", self.form_frame)

self.daten_label.setGeometry(720, 130, 150, 10)

self.dob_input = QDateEdit(self.form_frame)

self.dob_input.setGeometry(720, 140, 200, 40)

self.dob_input.setCalendarPopup (True)

self.dob_input.setDate(QDate.fromString(date_naissance,"yyyy-MM-dd"))

self.dob_input.setEnabled(False)

self.lieu_input = QLineEdit(self.form_frame)

self.lieu_input.setGeometry(970, 190, 220, 40)

self.lieu_input.setText(lieu_naissance)

self.lieu_input.setEnabled(False)

self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(35, 190, 220, 40)

self.address_input.setText(adresse)

self.address_input.setEnabled(False)

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(290, 190, 200, 40)

self.phone_input.setText(telephone)

self.phone_input.setEnabled(False)

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(510, 190, 350, 40)


self.email_input.setText(adresse_email)

self.email_input.setEnabled(False)

self.infoa = QLabel("INFORMATION STAGE :", self.form_frame)

self.infoa.setGeometry(25, 275, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(875, 320, 250, 40)

self.contact_input.setText(contact_urgence)

self.contact_input.setEnabled(False)

self.photo_str = photo

if photo:

photo_pixmap = QPixmap(photo).scaled(180,150,Qt.KeepAspectRatio)

self.photo_view = QLabel(self)

self.photo_view.setPixmap(photo_pixmap)

self.photo_view.setGeometry(940, 30, 180, 150)

self.service_input = QLineEdit(self.form_frame)

self.service_input.setGeometry(35, 320, 200, 40)

self.service_input.setPlaceholderText(" Service ")

self.siege_input = QLineEdit(self.form_frame)

self.siege_input.setGeometry(260, 320, 200, 40)

self.siege_input.setPlaceholderText("lieu du Siege ")

self.date_debut_input = QDateEdit(self.form_frame)
self.date_debut_input.setGeometry(485, 320, 220, 40)

self.date_debut_input.setCalendarPopup (True)

self.date_fin_input = QDateEdit(self.form_frame)

self.date_fin_input.setGeometry(730, 320, 220, 40)

self.date_fin_input.setCalendarPopup (True)

self.date_debut_input.dateChanged.connect(self.update_date_fin)

self.photo_label = QLabel(self.form_frame)

self.photo_label.setGeometry(940, 30, 180, 150)

self.statut_input = QLineEdit(self.form_frame)

self.statut_input.setGeometry(975, 320, 300, 40)

self.statut_input.setText("stagiaire")

self.cv_file = cv_file

if cv_file:

self.cv_button = QPushButton('voir CV', self.form_frame)

self.cv_button.setGeometry(35,440,250,125)

self.cv_button.clicked.connect(self.voir_cv)

save_button = QPushButton("Sauvegarder",self.form_frame)

save_button.setGeometry(800,460,150,35)

save_button.clicked.connect(self.save_data)

back_button = QPushButton("Retour",self.form_frame)
back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'affichage du stagiaire : {e}")

finally:

connexion.close()

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.enregistrement_page)

def update_date_fin(self):

date_debut = self.date_debut_input.date()

date_fin = date_debut.addMonths(3)

self.date_fin_input.setDate(date_fin)

def save_data(self):

nom_str = self.name_input.text()

prenom_str = self.surname_input.text()

date_naissance_str = self.dob_input.date().toString("dd/MM/yyyy")

lieu_naissance_str = self.lieu_input.text()

adresse_str= self.address_input.text()

telephone_str = self.phone_input.text()

adresse_email_str = self.email_input.text()

service_str = self.service_input.text()

siege_str = self.siege_input.text

date_debut_str = self.date_debut_input.date().toString("yyyy-MM-dd")

date_fin_str = self.date_fin_input.date().toString("yyyy-MM-dd")
cv_str = self.cv_file

photo_str = self.photo_str

statut_str = self.statut_input.text()

contact_urgence_str = self.contact_input.text()

if not service_str or not siege_str or not date_debut_str or not date_fin_str:

QMessageBox.warning(self,"Erreur","Veuillez remplir les champs obligatoires!!")

else:

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

requete = """ INSERT INTO stagiaire_renforcement (nom_str,prenom_str,date_naissance_str,


lieu_naissance_str,adresse_str,telephone_str,adresse_email_str,service_str,date_debut_str,date_fin_str
,contact_urgence_str,cv_str,photo_str,statut_str)

VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)

"""

valeurs = (nom_str,prenom_str,date_naissance_str,
lieu_naissance_str,adresse_str,telephone_str,adresse_email_str,service_str,date_debut_str,date_fin_str
,contact_urgence_str,cv_str,photo_str,statut_str)

curseur.execute(requete,valeurs)

connexion.commit()

QMessageBox.information(self,"Soumis",f"enregistrement du stagiaire {nom_str} a succes!")

finally:

connexion.close()

class PDFViewer(QMainWindow):
def __init__(self):

super().__init__()

self.init_ui()

def init_ui(self):

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

self.label = QLabel("pas de pdf charger",self.form_frame)

self.label.setGeometry(35,440,250,125)

self.label.setAlignment(Qt.AlignCenter)

self.setWindowTitle("Visualisation du CV")

self.setGeometry(100,100,800,600)

self.cv_button =QPushButton("chargement",self.form_frame)

self.cv_button.setGeometry(100,100,50,50)

self.cv_button.clicked.connect(self.load_pdf_from_db)
def load_pdf_from_db(self):

chemin_pdf = self.chemin(id)

if chemin_pdf :

self.display_pdf(chemin_pdf)

else:

self.label.setText("Aucun fichier PDF trouvé.")

def chemin(self, id):

try:

connexion = creer_connexion

curseur = connexion.cursor()

curseur.execute("SELECT cv FROM stage_renforcement WHERE id = ?",(id,))

result = curseur.fetchone()

connexion.close()

if result:

cv_file = result[0]

return cv_file

else:

print("aucun fichier trouver pour cet stagiaire.")

return None

except Exception as e:

print(f"Erreur lors de la recuperation du fichier : {e} ")

return None

def display_pdf(self, file_path):


doc = fitz.open(file_path)

page = doc.load_page(0)

pix = page.get_pixmap()

image = QPixmap.fromImage(self.convert_pix_to_quimage(pix))

self.label.setPixmap(self.scaled(self.label.size(),Qt.keepAspectRatio,Qt.SmoothTransformation))

doc.close()

def convert_pix_to_quimage(self, pix):

img = pix.samples

quimage = QImage(img,pix.width,pix.height,pix.stride, QImage.format_RGBA8888)

return quimage

class stagiaire(QMainWindow):

# les fonctions de la page stagiaire

def __init__(self,parent):

super().__init__()

self.parent = parent

self.init_ui()

def init_ui(self):

self.setWindowTitle("Gestion des stagiaires")


self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

self.stagiaire_ecole_button = QPushButton("Stagiaire - ecole",self.form_frame)

self.stagiaire_ecole_button.setGeometry(50,120,350,350)

self.stagiaire_ecole_button.clicked.connect(self.showecole)

self.stagiaire_immersion_button = QPushButton("Stagiaire - immersion",self.form_frame)

self.stagiaire_immersion_button.setGeometry(425,120,350,350)

self.stagiaire_immersion_button.clicked.connect(self.showimmersion)

self.stagiaire_perfectionnement_button = QPushButton("Stagiaire -
perfectionnement",self.form_frame)

self.stagiaire_perfectionnement_button.setGeometry(800,120,350,350)

self.stagiaire_perfectionnement_button.clicked.connect(self.showrenforcement)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

# gestion des stagiaires ecole


def showecole(self):

self.parent.stagiaire_ecole_page = stagiaires_ecole(self.parent)

self.parent.stacked_widget.addWidget(self.parent.stagiaire_ecole_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.stagiaire_ecole_page)

# gestion des stagiaires immersion

def showimmersion(self):

self.parent.stagiaire_immersion_page = stagiaires_immersion(self.parent)

self.parent.stacked_widget.addWidget(self.parent.stagiaire_immersion_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.stagiaire_immersion_page)

# gestion des stagiaires renforcement

def showrenforcement(self):

self.parent.stagiaire_renforcement_page = stagiaires_renforcement(self.parent)

self.parent.stacked_widget.addWidget(self.parent.stagiaire_renforcement_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.stagiaire_renforcement_page)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.accueil_page)

class stagiaires_ecole(QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.initUi()

self.show_stagiaire_ecole()
def initUi(self):

self.setWindowTitle("Stagiaires ecole")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

def show_stagiaire_ecole(self):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT id , nom_ste , prenom_ste , telephone_ste ,


photo_ste ,service_ste,siege_ste,date_debut_ste,date_fin_ste FROM stagiaire_ecole")

stagiaires = curseur.fetchall()

y = 50

for stagiaire in stagiaires:

id , nom_ste , prenom_ste , telephone_ste ,


photo_ste,service_ste,siege_ste,date_debut_ste,date_fin_ste = stagiaire

self.stagiaire_ecole_bloc(id,nom_ste,prenom_ste,telephone_ste ,
photo_ste,service_ste,siege_ste,date_debut_ste,date_fin_ste,y)

y+=175

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")


finally:

connexion.close()

def stagiaire_ecole_bloc(self,id_stagiaire, nom_ste ,prenom_ste,telephone_ste ,


photo_ste,service_ste,siege_ste,date_debut_ste,date_fin_ste,y):

frame = QFrame(self)

frame.setGeometry(140,y,670,180)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

nom_label= QLabel(f"Nom : {nom_ste}", frame)

nom_label.setGeometry(140,10,250,40)

nom_label.setFont(QtGui.QFont("Arial", 14))

prenom_label = QLabel(f"prenom : {prenom_ste}", frame)

prenom_label.setGeometry(140,40,250,40)

prenom_label.setFont(QtGui.QFont("Arial", 14))

telephone_label = QLabel(f"telephone : {telephone_ste}", frame)

telephone_label.setGeometry(140,70,250,40)

telephone_label.setFont(QtGui.QFont("Arial", 14))

service_label = QLabel(f"statut : {service_ste}", frame)

service_label.setGeometry(140,100,250,40)

service_label.setFont(QtGui.QFont("Arial", 14))

siege_label = QLabel(f"siege : {siege_ste}", frame)

siege_label.setGeometry(140,130,250,40)
siege_label.setFont(QtGui.QFont("Arial", 14))

date_debut_label = QLabel(f"date debut stage : {date_debut_ste}",frame)

date_debut_label.setGeometry(360,40,300,40)

date_debut_label.setFont(QtGui.QFont("Arial", 14))

date_fin_label = QLabel(f"date fin stage : {date_fin_ste}",frame)

date_fin_label.setGeometry(360,100,300,40)

date_fin_label.setFont(QtGui.QFont("Arial", 14))

if photo_ste:

pixmap = QPixmap(photo_ste).scaled(130,130,Qt.KeepAspectRatio,Qt.SmoothTransformation)

photo_label = QLabel(frame)

photo_label.setPixmap(pixmap)

photo_label.setGeometry(10,0,125,180)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

frame.mousePressEvent = lambda event , id = id_stagiaire: self.show_stagiaire_ecole_form(id)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.stagiaire_page)

class stagiaires_immersion(QMainWindow):
def __init__(self):

super().__init__()

self.initUi()

self.show_stagiaire_immersion()

def initUi(self):

self.setWindowTitle("Stagiaires immersion")

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

def show_stagiaire_immersion(self):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT id , nom_sti , prenom_sti , telephone_sti ,


photo_sti ,service_sti,siege_sti,date_debut_sti,date_fin_sti FROM stagiaire_immersion")

stagiaires = curseur.fetchall()
y = 50

for stagiaire in stagiaires:

id , nom_sti , prenom_sti , telephone_sti ,


photo_sti,service_sti,siege_sti,date_debut_sti,date_fin_sti = stagiaire

self.stagiaire_immersion_bloc(id,nom_sti,prenom_sti,telephone_sti ,
photo_sti,service_sti,siege_sti,date_debut_sti,date_fin_sti,y)

y+=175

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")

finally:

connexion.close()

def stagiaire_immersion_bloc(self,id_stagiaire, nom_sti ,prenom_sti,telephone_sti ,


photo_sti,service_sti,siege_sti,date_debut_sti,date_fin_sti,y):

frame = QFrame(self)

frame.setGeometry(140,y,670,180)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

nom_label= QLabel(f"Nom : {nom_sti}", frame)

nom_label.setGeometry(140,10,250,40)

nom_label.setFont(QtGui.QFont("Arial", 14))

prenom_label = QLabel(f"prenom : {prenom_sti}", frame)

prenom_label.setGeometry(140,40,250,40)

prenom_label.setFont(QtGui.QFont("Arial", 14))
telephone_label = QLabel(f"telephone : {telephone_sti}", frame)

telephone_label.setGeometry(140,70,250,40)

telephone_label.setFont(QtGui.QFont("Arial", 14))

service_label = QLabel(f"statut : {service_sti}", frame)

service_label.setGeometry(140,100,250,40)

service_label.setFont(QtGui.QFont("Arial", 14))

siege_label = QLabel(f"siege : {siege_sti}", frame)

siege_label.setGeometry(140,130,250,40)

siege_label.setFont(QtGui.QFont("Arial", 14))

date_debut_label = QLabel(f"date debut stage : {date_debut_sti}",frame)

date_debut_label.setGeometry(360,40,300,40)

date_debut_label.setFont(QtGui.QFont("Arial", 14))

date_fin_label = QLabel(f"date fin stage : {date_fin_sti}",frame)

date_fin_label.setGeometry(360,100,300,40)

date_fin_label.setFont(QtGui.QFont("Arial", 14))

if photo_sti:

pixmap = QPixmap(photo_sti).scaled(130,130,Qt.KeepAspectRatio,Qt.SmoothTransformation)

photo_label = QLabel(frame)

photo_label.setPixmap(pixmap)

photo_label.setGeometry(10,0,125,180)

back_button = QPushButton("Retour",self.form_frame)
back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.stagiaire_page)

class stagiaires_renforcement(QMainWindow):

def __init__(self):

super().__init__()

self.initUi()

self.show_stagiaire_renforcement()

def initUi(self):

self.setWindowTitle("Stagiaires renforcement")

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

def show_stagiaire_renforcement(self):
connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT id , nom_str , prenom_str , telephone_str ,


photo_str ,service_str,siege_str,date_debut_str,date_fin_str FROM stagiaire_renforcement")

stagiaires = curseur.fetchall()

y = 50

for stagiaire in stagiaires:

id , nom_str , prenom_str , telephone_str ,


photo_str,service_str,siege_str,date_debut_str,date_fin_str = stagiaire

self.stagiaire_renforcement_bloc(id,nom_str,prenom_str,telephone_str ,
photo_str,service_str,siege_str,date_debut_str,date_fin_str,y)

y+=175

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")

finally:

connexion.close()

def stagiaire_renforcement_bloc(self,id_stagiaire, nom_str ,prenom_str,telephone_str ,


photo_str,service_str,siege_str,date_debut_str,date_fin_str,y):

frame = QFrame(self)

frame.setGeometry(140,y,670,180)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

nom_label= QLabel(f"Nom : {nom_str}", frame)


nom_label.setGeometry(140,10,250,40)

nom_label.setFont(QtGui.QFont("Arial", 14))

prenom_label = QLabel(f"prenom : {prenom_str}", frame)

prenom_label.setGeometry(140,40,250,40)

prenom_label.setFont(QtGui.QFont("Arial", 14))

telephone_label = QLabel(f"telephone : {telephone_str}", frame)

telephone_label.setGeometry(140,70,250,40)

telephone_label.setFont(QtGui.QFont("Arial", 14))

service_label = QLabel(f"statut : {service_str}", frame)

service_label.setGeometry(140,100,250,40)

service_label.setFont(QtGui.QFont("Arial", 14))

siege_label = QLabel(f"siege : {siege_str}", frame)

siege_label.setGeometry(140,130,250,40)

siege_label.setFont(QtGui.QFont("Arial", 14))

date_debut_label = QLabel(f"date debut stage : {date_debut_str}",frame)

date_debut_label.setGeometry(360,40,300,40)

date_debut_label.setFont(QtGui.QFont("Arial", 14))

date_fin_label = QLabel(f"date fin stage : {date_fin_str}",frame)

date_fin_label.setGeometry(360,100,300,40)

date_fin_label.setFont(QtGui.QFont("Arial", 14))

if photo_str:
pixmap = QPixmap(photo_str).scaled(130,130,Qt.KeepAspectRatio,Qt.SmoothTransformation)

photo_label = QLabel(frame)

photo_label.setPixmap(pixmap)

photo_label.setGeometry(10,0,125,180)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.stagiaire_page)

class SuiviPage(QWidget):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.init_ui()

def init_ui(self):

self.setWindowTitle("Type de Demande")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;
""")

self.suivi_ecole_button = QPushButton("Stage ecole",self.form_frame)

self.suivi_ecole_button.setGeometry(50,120,350,350)

self.suivi_ecole_button.clicked.connect(self.enreg_suivi_ecole)

self.suivi_immersion_button = QPushButton("Stage d'immersion",self.form_frame)

self.suivi_immersion_button.setGeometry(425,120,350,350)

self.suivi_immersion_button.clicked.connect(self.enreg_suivi_immersion)

self.suivi_renforcement_button = QPushButton("Stage de renforcement",self.form_frame)

self.suivi_renforcement_button.setGeometry(800,120,350,350)

self.suivi_renforcement_button.clicked.connect(self.enreg_suivi_renforcement)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

def enreg_suivi_ecole(self):

self.parent.enre_suivi_ecole = enregistrement_suivi_ecole(self.parent)

self.parent.stacked_widget.addWidget(self.parent.enre_suivi_ecole)

self.parent.stacked_widget.setCurrentWidget(self.parent.enre_suivi_ecole)

# enregistrement stagiaire immersion

def enreg_suivi_immersion(self):

self.parent.enre_suivi_immersion = enregistrement_suivi_immersion(self.parent)

self.parent.stacked_widget.addWidget(self.parent.enre_suivi_immersion)

self.parent.stacked_widget.setCurrentWidget(self.parent.enre_suivi_immersion)
# enregistrement stagiaire renforcement

def enreg_suivi_renforcement(self):

self.parent.enre_suivi_renforcement = enregistrement_suivi_renforcement(self.parent)

self.parent.stacked_widget.addWidget(self.parent.enre_suivi_renforcement)

self.parent.stacked_widget.setCurrentWidget(self.parent.enre_suivi_renforcement)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.accueil_page)

class enregistrement_suivi_ecole(QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.initUI()

self.show_suivi_ecole()

def initUI(self):

self.setWindowTitle("Suivi - Stagiaire ecole")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")
def show_suivi_ecole(self):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT id , nom_ste , prenom_ste , telephone_ste , photo_ste , statut_ste,


date_debut_ste, date_fin_ste,date_enregistrement_ste, jours_counter_ste FROM stagiaire_ecole")

stagiaires = curseur.fetchall()

y = 50

for stagiaire in stagiaires:

id , nom_ste , prenom_ste , telephone_ste ,


photo_ste,statut_ste,date_debut_ste,date_fin_ste,date_enregistrement_ste, jours_counter_ste=
stagiaire

self.create_suivi_ecole_bloc(id,nom_ste,prenom_ste,telephone_ste ,
photo_ste,statut_ste,date_debut_ste,date_fin_ste,date_enregistrement_ste, jours_counter_ste,y)

y+=175

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")

finally:

connexion.close()

def create_suivi_ecole_bloc(self,id_stagiaire, nom_ste ,prenom_ste,telephone_ste ,


photo_ste,statut_ste,date_debut_ste,date_fin_ste,date_enregistrement_ste, jours_counter_ste,y):

frame = QFrame(self)

frame.setGeometry(140,y,700,180)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")


nom_label= QLabel(f"Nom : {nom_ste}", frame)

nom_label.setGeometry(140,10,250,40)

nom_label.setFont(QtGui.QFont("Arial", 14))

prenom_label = QLabel(f"prenom : {prenom_ste}", frame)

prenom_label.setGeometry(140,40,250,40)

prenom_label.setFont(QtGui.QFont("Arial", 14))

telephone_label = QLabel(f"telephone : {telephone_ste}", frame)

telephone_label.setGeometry(140,70,250,40)

telephone_label.setFont(QtGui.QFont("Arial", 14))

statut_label = QLabel(f"statut : {statut_ste}", frame)

statut_label.setGeometry(140,100,300,50)

statut_label.setFont(QtGui.QFont("Arial", 16))

date_enregistrement_label = QLabel(f"Date d'enregistrement : {date_enregistrement_ste}",frame)

date_enregistrement_label.setGeometry(360,10,330,40)

date_enregistrement_label.setFont(QtGui.QFont("Arial", 14))

date_debut_label = QLabel(f"Date debut stage : {date_debut_ste}",frame)

date_debut_label.setGeometry(360,40,300,40)

date_debut_label.setFont(QtGui.QFont("Arial", 14))

date_fin_label = QLabel(f"Date fin stage : {date_fin_ste}",frame)

date_fin_label.setGeometry(360,70,300,40)

date_fin_label.setFont(QtGui.QFont("Arial", 14))
jours_effectuer_label = QLabel(f"Jours effectué : {jours_counter_ste}",frame)

jours_effectuer_label.setGeometry(360,100,300,40)

jours_effectuer_label.setFont(QtGui.QFont("Arial", 14))

if photo_ste:

pixmap = QPixmap(photo_ste).scaled(130,130,Qt.KeepAspectRatio,Qt.SmoothTransformation)

photo_label = QLabel(frame)

photo_label.setPixmap(pixmap)

photo_label.setGeometry(10,0,125,180)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

frame.mousePressEvent = lambda event , id = id_stagiaire: self.suivie_ecole_form(id_stagiaire)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.suivi_page)

def suivie_ecole_form(self,id_stagiaire) :

self.setWindowTitle("Formulaire complet du stagiaire")

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)
self.suivie_ecole_Page = QWidget()

self.stacked.addWidget(self.suivie_ecole_Page)

self.form_frame = QtWidgets.QFrame(self.suivie_ecole_Page)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

frame = QFrame(self.form_frame)

frame.setGeometry(25,400,400,100)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT
nom_ste,prenom_ste,adresse_ste,telephone_ste,adresse_email_ste,contact_urgence__ste,photo_ste,d
ate_debut_ste, date_fin_ste,date_enregistrement_ste, jours_counter_ste FROM stagiaire_ecole WHERE
id = %s",(id_stagiaire,))

stagiaire = curseur.fetchone()

print(id_stagiaire)

print(stagiaire)

if stagiaire:

(nom_ste,prenom_ste,adresse_ste,telephone_ste,adresse_email_ste,contact_urgence__ste,photo_ste,d
ate_debut_ste, date_fin_ste,date_enregistrement_ste, jours_counter_ste) = stagiaire
self.title = QLabel("ENREGISTREMENT DE STAGIAIRE (STAGE renforcement) ",
self.form_frame)

self.title.setGeometry(125, 25, 650, 50)

self.title.setFont(QtGui.QFont("Arial", 16))

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)

self.infop.setGeometry(25, 90, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 135, 220, 40)

self.name_input.setText(nom_ste)

self.name_input.setReadOnly(True)

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 135, 300, 40)

self.surname_input.setText(prenom_ste)

self.surname_input.setReadOnly(True)

self.address_input = QLineEdit(self.form_frame)

self.address_input.setGeometry(605, 135, 220, 40)

self.address_input.setText(adresse_ste)

self.address_input.setReadOnly(True)

self.phone_input = QLineEdit(self.form_frame)

self.phone_input.setGeometry(35, 190, 200, 40)

self.phone_input.setText(telephone_ste)
self.phone_input.setReadOnly(True)

self.email_input = QLineEdit(self.form_frame)

self.email_input.setGeometry(280, 190, 300, 40)

self.email_input.setText(adresse_email_ste)

self.email_input.setReadOnly(True)

self.contact_input = QLineEdit(self.form_frame)

self.contact_input.setGeometry(605, 190, 250, 40)

self.contact_input.setText(contact_urgence__ste)

self.contact_input.setReadOnly(True)

self.date_debut_label = QLabel("Date de debut de stage",self.form_frame)

self.date_debut_label.setGeometry(35,250,200,20)

date_debut_pi = date_debut_ste.strftime("%Y-%m-%d")

qdatedeb = QDate.fromString(date_debut_pi,"yyyy-MM-dd")

self.date_debut_input = QDateEdit(self.form_frame)

self.date_debut_input.setGeometry(35, 285, 200, 40)

self.date_debut_input.setCalendarPopup(True)

self.date_debut_input.setDate(qdatedeb)

self.date_debut_input.setReadOnly(True)

self.date_fin_label = QLabel("Date de fin de stage",self.form_frame)

self.date_fin_label.setGeometry(280,250,200,20)

date_fin_pi = date_fin_ste.strftime("%Y-%m-%d")

qdatefin = QDate.fromString(date_fin_pi,"yyyy-MM-dd")

self.date_fin_input = QDateEdit(self.form_frame)

self.date_fin_input.setGeometry(280, 285, 200, 40)

self.date_fin_input.setCalendarPopup(True)
self.date_fin_input.setDate(qdatefin)

self.date_fin_input.setEnabled(False)

self.date_enr_label = QLabel("Date d'enregistrement",self.form_frame)

self.date_enr_label.setGeometry(505,250,200,20)

date_enr_pi = date_enregistrement_ste.strftime("%Y-%m-%d")

qdateenr = QDate.fromString(date_enr_pi,"yyyy-MM-dd")

self.date_enregistrement_input = QDateEdit(self.form_frame)

self.date_enregistrement_input.setGeometry(505, 285, 200, 40)

self.date_enregistrement_input.setCalendarPopup(True)

self.date_enregistrement_input.setDate(qdateenr)

self.date_enregistrement_input.setReadOnly(True)

self.date_counter_label = QLabel("Jours effectué a ce jour",self.form_frame)

self.date_counter_label.setGeometry(730,250,200,20)

self.date_counter_input = QLineEdit(self.form_frame)

self.date_counter_input.setGeometry(730, 285, 200, 40)

self.date_counter_input.setText(jours_counter_ste)

self.date_counter_input.setEnabled(False)

photo_pixmap = QPixmap(photo_ste).scaled(180,150,Qt.KeepAspectRatio)

self.photo_view = QLabel(self)

self.photo_view.setPixmap(photo_pixmap)

self.photo_view.setGeometry(940, 30, 180, 150)

self.tab_widget = QTabWidget(self.form_frame)

self.infoa = QLabel("SUIVI DU STAGIAIRE :", self.form_frame)


self.infoa.setGeometry(25, 350, 350, 30)

self.infoa.setFont(QtGui.QFont("Arial", 16))

ajouter_button = QPushButton("Accepter",self.form_frame)

ajouter_button.setGeometry(800,460,150,35)

ajouter_button.clicked.connect(lambda: self.add_evaluation_form(id_stagiaire))

modifier_button = QPushButton("modifier",self.form_frame)

modifier_button.setGeometry(800,510,150,35)

modifier_button.clicked.connect(self.modify_evaluation_form)

supprimer_button = QPushButton("supprimer",self.form_frame)

supprimer_button.setGeometry(800,560,150,35)

supprimer_button.clicked.connect(self.delete_evaluation_form)

voir_liste = QPushButton(" voir la liste des formulaires",self.form_frame)

voir_liste.setGeometry(600,560,200,200)

voir_liste.clicked.connect(lambda : self.voir(id_stagiaire))

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'affichage du stagiaire : {e}")

finally:

connexion.close()

def add_evaluation_form(self,id_stagiaire):

self.parent.form_page = evaluationform(self.parent,id_stagiaire)

self.parent.stacked_widget.addWidget(self.parent.form_page)
self.parent.stacked_widget.setCurrentWidget(self.parent.form_page)

def modify_evaluation_form(self):

current_tab = self.tab_widget.currentWidget()

if current_tab:

self.form_dialog = evaluationform(self,current_tab.data)

self.form_dialog.show()

def delete_evaluation_form(self):

current_index = self.tab_widget.currentIndex()

if current_index != -1:

reply = QMessageBox.question(self,"Confirmation","Voulez vous vraiment supprimer ce


formulaire ?", QMessageBox.Yes | QMessageBox.No)

if reply == QMessageBox.Yes:

self.tab_widget.removeTab(current_index)

def voir (self,id_stagiaire):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT id ,
nom_este,date_evaluation_etse,assiduite_este,conduite_este,evolution_este,participation_este,capacit
e_este,date_enregistrement_este,counter_este FROM evaluation_ste")

stagiaires = curseur.fetchall()

y = 50

print(id_stagiaire)

for stagiaire in stagiaires:

id_stagiaire = stagiaire[0]

nom_este = stagiaire[1]
date_evaluation_etse= stagiaire[2]

assiduite_este= stagiaire[3]

conduite_este= stagiaire[4]

evolution_este= stagiaire[5]

participation_este= stagiaire[6]

capacite_este= stagiaire[7]

date_enregistrement_este= stagiaire[8]

counter_este = stagiaire[9]

print(id_stagiaire)

print(stagiaire)

curseur.execute("SELECT COUNT (*) FROM evaluation_ste WHERE counter_este= %s order by


counter_este DESC LIMIT 1",(id_stagiaire,))

resultat = curseur.fetchone()

counter_este = resultat[0]+1 if resultat else 1

print(f" Stagiaire: {nom_este}")

print(f" Nombre d'evaluation:{counter_este} ")

curseur.execute(""" INSERT INTO


evaluation_ste(id,nom_este,date_evaluation_etse,assiduite_este,conduite_este,evolution_este,participa
tion_este,capacite_este,date_enregistrement_este,counter_este FROM evaluation_ste)

VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)""",(id_stagiaire,counter_este))

self.voir_liste(id_stagiaire ,
nom_este,date_evaluation_etse,assiduite_este,conduite_este,evolution_este,participation_este,capacit
e_este,date_enregistrement_este,y)

y+=150

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")

finally:

connexion.close()
def voir_liste
(self,id_stagiaire,nom_este,date_evaluation_etse,assiduite_este,conduite_este,evolution_este,participa
tion_este,capacite_este,date_enregistrement_este,y):

self.form_frame = QtWidgets.QFrame(self.suivie_ecole_Page)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

frame = QFrame(self.form_frame)

frame.setGeometry(25,400,400,100)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

connexion = creer_connexion()

if connexion:

curseur = connexion.cursor()

curseur.execute("SELECT
nom_este,date_evaluation_etse,assiduite_este,conduite_este,evolution_este,participation_este,capacit
e_este,date_enregistrement_este FROM evaluation_ste WHERE id = %s",(id_stagiaire,))

stagiaire = curseur.fetchone()

print(id_stagiaire)

print(stagiaire)

if stagiaire :

(nom_este,date_evaluation_etse,assiduite_este,conduite_este,evolution_este,participation_este,capacit
e_este,date_enregistrement_este ) = stagiaire
nom_label= QLabel(f"Nom : {nom_este}", frame)

nom_label.setGeometry(10,10,100,20)

nom_label.setFont(QtGui.QFont("Arial", 14))

date_eva_label= QLabel(f"Date evaluation : {date_evaluation_etse}", frame)

date_eva_label.setGeometry(10,40,100,20)

date_eva_label.setFont(QtGui.QFont("Arial", 14))

assiduite_label= QLabel(f"assiduité : {assiduite_este}", frame)

assiduite_label.setGeometry(10,70,250,20)

assiduite_label.setFont(QtGui.QFont("Arial", 14))

conduite_label= QLabel(f"conduite : {conduite_este}", frame)

conduite_label.setGeometry(10,100,250,20)

conduite_label.setFont(QtGui.QFont("Arial", 14))

evolution_label= QLabel(f"evolution : {evolution_este}", frame)

evolution_label.setGeometry(10,130,250,20)

evolution_label.setFont(QtGui.QFont("Arial", 14))

participation_label= QLabel(f"participation : {participation_este}", frame)

participation_label.setGeometry(10,160,250,20)

participation_label.setFont(QtGui.QFont("Arial", 14))

capacite_label= QLabel(f"capacite : {capacite_este}", frame)

capacite_label.setGeometry(10,190,250,20)

capacite_label.setFont(QtGui.QFont("Arial", 14))

date_enr_label= QLabel(f"date enregistrement : {date_enregistrement_este}", frame)


date_enr_label.setGeometry(10,220,250,20)

date_enr_label.setFont(QtGui.QFont("Arial", 14))

class enregistrement_suivi_immersion(QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.initUI()

self.show_suivi_immersion()

def initUI(self):

self.setWindowTitle("Suivi - Stagiaire immersion")

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

def show_suivi_immersion(self):

connexion = creer_connexion()

if connexion:

try:
curseur = connexion.cursor()

curseur.execute("SELECT id , nom_sti , prenom_sti , telephone_sti , photo_sti , statut_sti,


date_debut_sti, date_fin_sti,date_enregistrement_sti, jours_counter_sti FROM stagiaire_ecole")

stagiaires = curseur.fetchall()

y = 50

for stagiaire in stagiaires:

id , nom_sti , prenom_sti , telephone_sti ,


photo_sti,statut_sti,date_debut_sti,date_fin_sti,date_enregistrement_sti, jours_counter_sti= stagiaire

self.create_suivi_immersion_bloc(id,nom_sti,prenom_sti,telephone_sti ,
photo_sti,statut_sti,date_debut_sti,date_fin_sti,date_enregistrement_sti, jours_counter_sti,y)

y+=175

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")

finally:

connexion.close()

def create_suivi_immersion_bloc(self,id_stagiaire, nom_sti ,prenom_sti,telephone_sti ,


photo_sti,statut_sti,date_debut_sti,date_fin_sti,date_enregistrement_sti, jours_counter_sti,y):

frame = QFrame(self)

frame.setGeometry(140,y,700,180)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

nom_label= QLabel(f"Nom : {nom_sti}", frame)

nom_label.setGeometry(140,10,250,40)

nom_label.setFont(QtGui.QFont("Arial", 14))

prenom_label = QLabel(f"prenom : {prenom_sti}", frame)

prenom_label.setGeometry(140,40,250,40)
prenom_label.setFont(QtGui.QFont("Arial", 14))

telephone_label = QLabel(f"telephone : {telephone_sti}", frame)

telephone_label.setGeometry(140,70,250,40)

telephone_label.setFont(QtGui.QFont("Arial", 14))

statut_label = QLabel(f"statut : {statut_sti}", frame)

statut_label.setGeometry(140,100,300,50)

statut_label.setFont(QtGui.QFont("Arial", 16))

date_enregistrement_label = QLabel(f"Date d'enregistrement : {date_enregistrement_sti}",frame)

date_enregistrement_label.setGeometry(360,10,330,40)

date_enregistrement_label.setFont(QtGui.QFont("Arial", 14))

date_debut_label = QLabel(f"Date debut stage : {date_debut_sti}",frame)

date_debut_label.setGeometry(360,40,300,40)

date_debut_label.setFont(QtGui.QFont("Arial", 14))

date_fin_label = QLabel(f"Date fin stage : {date_fin_sti}",frame)

date_fin_label.setGeometry(360,70,300,40)

date_fin_label.setFont(QtGui.QFont("Arial", 14))

jours_effectuer_label = QLabel(f"Jours effectué : {jours_counter_sti}",frame)

jours_effectuer_label.setGeometry(360,100,300,40)

jours_effectuer_label.setFont(QtGui.QFont("Arial", 14))

if photo_sti:

pixmap = QPixmap(photo_sti).scaled(130,130,Qt.KeepAspectRatio,Qt.SmoothTransformation)
photo_label = QLabel(frame)

photo_label.setPixmap(pixmap)

photo_label.setGeometry(10,0,125,180)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

frame.mousePressEvent = lambda event , id = id_stagiaire: self.show_stagiaire_ecole_form(id)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.suivi_page)

class enregistrement_suivi_renforcement(QMainWindow):

def __init__(self,parent):

super().__init__()

self.parent = parent

self.initUI()

self.show_suivi_renforcement()

def initUI(self):

self.setWindowTitle("Suivi - Stagiaire immersion")

self.form_frame = QtWidgets.QFrame(self)
self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

def show_suivi_renforcement(self):

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

curseur.execute("SELECT id , nom_str , prenom_str , telephone_str , photo_str , statut_str,


date_debut_str, date_fin_str,date_enregistrement_str, jours_counter_str FROM stagiaire_ecole")

stagiaires = curseur.fetchall()

y = 50

for stagiaire in stagiaires:

id , nom_str , prenom_str , telephone_str ,


photo_str,statut_str,date_debut_str,date_fin_str,date_enregistrement_str, jours_counter_str= stagiaire

self.create_suivi_renforcement_bloc(id,nom_str,prenom_str,telephone_str ,
photo_str,statut_str,date_debut_str,date_fin_str,date_enregistrement_str, jours_counter_str,y)

y+=175

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors du chargement des stagiaires : {e}")

finally:

connexion.close()

def create_suivi_renforcement_bloc(self,id_stagiaire, nom_str ,prenom_str,telephone_str ,


photo_str,statut_str,date_debut_str,date_fin_str,date_enregistrement_str, jours_counter_str,y):
frame = QFrame(self)

frame.setGeometry(140,y,700,180)

frame.setFrameShape(QFrame.Box)

frame.setStyleSheet("background-color : lightgray; margin:10px; border-radius: 15px;")

nom_label= QLabel(f"Nom : {nom_str}", frame)

nom_label.setGeometry(140,10,250,40)

nom_label.setFont(QtGui.QFont("Arial", 14))

prenom_label = QLabel(f"prenom : {prenom_str}", frame)

prenom_label.setGeometry(140,40,250,40)

prenom_label.setFont(QtGui.QFont("Arial", 14))

telephone_label = QLabel(f"telephone : {telephone_str}", frame)

telephone_label.setGeometry(140,70,250,40)

telephone_label.setFont(QtGui.QFont("Arial", 14))

statut_label = QLabel(f"statut : {statut_str}", frame)

statut_label.setGeometry(140,100,300,50)

statut_label.setFont(QtGui.QFont("Arial", 16))

date_enregistrement_label = QLabel(f"Date d'enregistrement : {date_enregistrement_str}",frame)

date_enregistrement_label.setGeometry(360,10,330,40)

date_enregistrement_label.setFont(QtGui.QFont("Arial", 14))

date_debut_label = QLabel(f"Date debut stage : {date_debut_str}",frame)

date_debut_label.setGeometry(360,40,300,40)

date_debut_label.setFont(QtGui.QFont("Arial", 14))
date_fin_label = QLabel(f"Date fin stage : {date_fin_str}",frame)

date_fin_label.setGeometry(360,70,300,40)

date_fin_label.setFont(QtGui.QFont("Arial", 14))

jours_effectuer_label = QLabel(f"Jours effectué : {jours_counter_str}",frame)

jours_effectuer_label.setGeometry(360,100,300,40)

jours_effectuer_label.setFont(QtGui.QFont("Arial", 14))

if photo_str:

pixmap = QPixmap(photo_str).scaled(130,130,Qt.KeepAspectRatio,Qt.SmoothTransformation)

photo_label = QLabel(frame)

photo_label.setPixmap(pixmap)

photo_label.setGeometry(10,0,125,180)

back_button = QPushButton("Retour",self.form_frame)

back_button.setGeometry(1000,550,100,55)

back_button.clicked.connect(self.go_back)

frame.mousePressEvent = lambda event , id = id_stagiaire: self.show_stagiaire_ecole_form(id)

def go_back(self):

self.parent.stacked_widget.setCurrentWidget(self.parent.suivi_page)

class evaluationform(QMainWindow):

def __init__(self,parent,id_stagiaire,data=None):
super().__init__(parent)

self.setWindowTitle("formulaire d'evaluation")

self.setGeometry(100,100,700,400)

self.data = data

self.parent = parent

self.id_stagiaire = id_stagiaire

self.init_ui(id_stagiaire)

def init_ui(self,id_stagiaire):

self.form_frame = QtWidgets.QFrame(self)

self.form_frame.setGeometry(125, 50, 1200, 625)

self.form_frame.setStyleSheet("""

background-color: rgba(255, 255, 255, 0.5);

border-radius: 15px;

""")

self.title_label = QLabel("FICHE D'EVALUATION DU STAGIAIRE",self.form_frame)

self.title_label.setGeometry(20,20,250,20)

connexion = creer_connexion()

if connexion:

curseur = connexion.cursor()

curseur.execute("SELECT nom_ste,prenom_ste,photo_ste,date_debut_ste,
date_fin_ste,date_enregistrement_ste, jours_counter_ste,service_ste,siege_ste FROM stagiaire_ecole
WHERE id = %s",(id_stagiaire,))
stagiaire = curseur.fetchone()

print(id_stagiaire)

print(stagiaire)

if stagiaire:

(nom_ste,prenom_ste,photo_ste,date_debut_ste, date_fin_ste,date_enregistrement_ste,
jours_counter_ste,service_ste,siege_ste) = stagiaire

self.infop = QLabel("INFORMATION PERSONNELLE :", self.form_frame)

self.infop.setGeometry(25, 75, 350, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.name_input = QLineEdit(self.form_frame)

self.name_input.setGeometry(35, 120, 180, 40)

self.name_input.setText(nom_ste)

self.name_input.setEnabled(False)

self.surname_input = QLineEdit(self.form_frame)

self.surname_input.setGeometry(280, 120, 300, 40)

self.surname_input.setText(prenom_ste)

self.surname_input.setEnabled(False)

date_debut_pi = date_debut_ste.strftime("%Y-%m-%d")

qdatedeb = QDate.fromString(date_debut_pi,"yyyy-MM-dd")

self.date_debut_input = QDateEdit(self.form_frame)

self.date_debut_input.setGeometry(35, 190, 200, 40)

self.date_debut_input.setCalendarPopup (True)

self.date_debut_input.setDate(qdatedeb)

self.date_debut_input.setEnabled(False)
date_fin_pi = date_fin_ste.strftime("%Y-%m-%d")

qdatefin = QDate.fromString(date_fin_pi,"yyyy-MM-dd")

self.date_fin_input = QDateEdit(self.form_frame)

self.date_fin_input.setGeometry(260, 190, 200, 40)

self.date_fin_input.setCalendarPopup (True)

self.date_fin_input.setDate(qdatefin)

self.date_fin_input.setEnabled(False)

date_enr_pi = date_enregistrement_ste.strftime("%Y-%m-%d")

qdateenr = QDate.fromString(date_enr_pi,"yyyy-MM-dd")

self.date_enregistrement_input = QDateEdit(self.form_frame)

self.date_enregistrement_input.setGeometry(485, 190, 200, 40)

self.date_enregistrement_input.setCalendarPopup (True)

self.date_enregistrement_input.setDate(qdateenr)

self.date_enregistrement_input.setEnabled(False)

self.date_counter_input = QLineEdit(self.form_frame)

self.date_counter_input.setGeometry(710, 190, 200, 40)

self.date_counter_input.setText(jours_counter_ste)

self.date_counter_input.setEnabled(False)

self.infop = QLabel("INFORMATION DU MAITRE DE STAGE :", self.form_frame)

self.infop.setGeometry(25, 280, 425, 30)

self.infop.setFont(QtGui.QFont("Arial", 16))

self.label_supervisor = QLabel("NOM DU MAITRE DE STAGE",self.form_frame)

self.label_supervisor.setGeometry(35,325,200,20)

self.input_supervisor = QLineEdit(self.form_frame)
self.input_supervisor.setGeometry(35,350,300,20)

self.label_service = QLabel("Service : ",self.form_frame)

self.label_service.setGeometry(35,375,200,20)

self.input_service = QLineEdit(self.form_frame)

self.input_service.setGeometry(35,400,300,20)

self.input_service.setText(service_ste)

self.input_service.setEnabled(False)

self.label_siege = QLabel("Siege : ",self.form_frame)

self.label_siege.setGeometry(35,425,200,20)

self.input_siege = QLineEdit(self.form_frame)

self.input_siege.setGeometry(35,450,300,20)

self.input_siege.setText(siege_ste)

self.input_siege.setEnabled(False)

line = QFrame(self.form_frame)

line.setGeometry(475,280,3,300)

line.setFrameShape(QFrame.VLine)

line.setFrameShadow(QFrame.Sunken)

self.label_criteria = QLabel("CRITERE D'EVALUATION",self.form_frame)

self.label_criteria.setGeometry(500,280,425,30)

self.label_assiduite = QLabel("1. Assiduité et ponctualité",self.form_frame)

self.label_assiduite.setGeometry(500,325,200,20)

self.input_assiduite = QComboBox(self.form_frame)

self.input_assiduite.setGeometry(750,325,100,20)
self.input_assiduite.addItems(["","1","2","3","4","5"])

self.label_conduite = QLabel("2. Conduite",self.form_frame)

self.label_conduite.setGeometry(500,375,200,20)

self.input_conduite = QComboBox(self.form_frame)

self.input_conduite.setGeometry(750,375,100,20)

self.input_conduite.addItems(["","1","2","3","4","5"])

self.label_evolution = QLabel("3. Etat d'evolution de la formation",self.form_frame)

self.label_evolution.setGeometry(500,425,200,20)

self.input_evolution = QComboBox(self.form_frame)

self.input_evolution.setGeometry(750,425,100,20)

self.input_evolution.addItems(["","1","2","3","4","5"])

self.label_participation = QLabel("4. Participation aux activités du stage",self.form_frame)

self.label_participation.setGeometry(500,475,200,20)

self.input_participation = QComboBox(self.form_frame)

self.input_participation.setGeometry(750,475,100,20)

self.input_participation.addItems(["","1","2","3","4","5"])

self.label_capacite = QLabel("5. Capacité d'adaptation",self.form_frame)

self.label_capacite.setGeometry(500,525,200,20)

self.input_capacite = QComboBox(self.form_frame)

self.input_capacite.setGeometry(750,525,100,20)

self.input_capacite.addItems(["","1","2","3","4","5"])

photo_pixmap = QPixmap(photo_ste).scaled(180,150,Qt.KeepAspectRatio)

self.photo_view = QLabel(self.form_frame)
self.photo_view.setPixmap(photo_pixmap)

self.photo_view.setGeometry(900, 10, 180, 150)

if self.data:

self.input_assiduite.setCurrentText(self.data.get('Assiduité',''))

self.input_conduite.setCurrentText(self.data.get('Conduite',''))

self.input_evolution.setCurrentText(self.data.get('Etat d''evolution de la formation',''))

self.input_participation.setCurrentText(self.data.get('Participation aux activités du stage',''))

self.input_capacite.setCurrentText(self.data.get('Capacité d''adaptation',''))

self.save_button = QPushButton("Sauvegarder",self.form_frame)

self.save_button.setGeometry(900,460,200,130)

self.save_button.clicked.connect(self.save_data)

def save_data(self):

data =
{"Assiduite":self.input_assiduite.currentText(),"Conduite":self.input_conduite.currentText(),"Evolution":s
elf.input_evolution.currentText(),"Participation":
self.input_participation.currentText(),"Capacite":self.input_capacite.currentText(),"Date":QDate.current
Date().toString("dd/MM/yyyy")}

nom_este = self.name_input.text()

prenom_este = self.surname_input.text()

date_debut_este = self.date_debut_input.date().toString("dd/MM/yyyy")

date_fin_este = self.date_fin_input.date().toString("dd/MM/yyyy")

date_enregistrement_este = self.date_enregistrement_input.date().toString("dd/MM/yyyy")

supervisor_este = self.input_supervisor.text()

service_este = self.input_service.text()

siege_este = self.input_siege.text()

jours_counter_este = self.date_counter_input.text()
assiduite_este = data['Assiduite']

conduite_este = data['Conduite']

evolution_este = data['Evolution']

participation_este = data['Participation']

capacite_este = data['Capacite']

photo_este = self.photo_view.text()

connexion = creer_connexion()

if connexion:

try:

curseur = connexion.cursor()

requete = """ INSERT INTO evaluation_ste


(nom_este,prenom_este,date_debut_este,date_fin_este,date_enregistrement_este,supervisor_este,ser
vice_este,siege_este,jours_counter_este,conduite_este,assiduite_este,evolution_este,participation_este
,capacite_este,photo_este)

VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)

"""

valeurs =
(nom_este,prenom_este,date_debut_este,date_fin_este,date_enregistrement_este,supervisor_este,ser
vice_este,siege_este,jours_counter_este,conduite_este,assiduite_este,evolution_este,participation_este
,capacite_este,photo_este)

curseur.execute(requete,valeurs)

connexion.commit()

QMessageBox.information(self,"Succès","les données ont été enregistrées avec succès dans la


base de données")

self.parent.accueil_page= Accueil(self.parent)

self.parent.stacked_widget.addWidget(self.parent.accueil_page)

self.parent.stacked_widget.setCurrentWidget(self.parent.accueil_page)

except Error as e:

QMessageBox.warning(self,"Erreur",f"Erreur lors de l'enregistrement : {e}")


finally:

connexion.close()

if __name__ == "__main__":

app = QApplication([])

main_window = Login()

main_window.showMaximized()

app.exec_()

You might also like