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

Ecole 4

Ecole4

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 views104 pages

Ecole 4

Ecole4

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/ 104

from PyQt5.

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


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

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 Accueil(QWidget):

def __init__(self):
super().__init__()

layout = QVBoxLayout(self)

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

layout.addWidget(label)

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 = QStackedWidget()

self.setCentralWidget(self.stacked)

# Page de connexion

self.login_page = QWidget()

self.stacked.addWidget(self.login_page)

# Cadre central pour simuler le verre

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

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)

#panneau lateral

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

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

#bouton menu panneau lateral

self.menu_layout = QVBoxLayout(self.side_menu)

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

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

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

self.menu_layout.addWidget(self.enregistrement)

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

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

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

self.menu_layout.addWidget(self.stagiaire)

self.maitre = QPushButton("Maitre de Stage", self)

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

self.maitre.clicked.connect(self.show_maitre_page)

self.menu_layout.addWidget(self.maitre)

self.validation = QPushButton("Validation", self)

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

self.validation.clicked.connect(self.show_validation_page)

self.menu_layout.addWidget(self.validation)

#bouton pour ouvrir/fermer menu

self.toggle_button = QPushButton("|||",self)
self.toggle_button.setGeometry(10,10,30,30)

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

self.toggle_button.hide()

# Dictionnaire pour stocker les pages

self.pages = {}

global history

history = []

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 self.pages :

self.pages['accueil']= Accueil()

self.stacked.addWidget(self.pages['accueil'])

self.stacked.setCurrentWidget(self.pages['accueil'])

self.toggle_button.show()

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")

# les fonctions de la page enregistrement

# la fonction de la demande d'enregistrement

def show_enregistrement_page(self):

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

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

current_index = self.stacked.currentIndex()

history.append(current_index)

self.enregistrement_page = QWidget(self)

self.stacked.addWidget(self.enregistrement_page)

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

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,100,500,500)
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(600,100,500,500)

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

self.stacked.addWidget(self.enregistrement_page)

self.stacked.setCurrentWidget(self.enregistrement_page)

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

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

back_button.clicked.connect(self.go_back)

# enregistrement de demande de stage

def show_demande_stage_page(self):

self.setWindowTitle("Type de Demande")

current_index = self.stacked.currentIndex()

history.append(current_index)

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.demande_stage_page = QWidget(self)

self.stacked.addWidget(self.demande_stage_page)

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

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)

self.stacked.setCurrentWidget(self.demande_stage_page)

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):

if len (history) > 0:


previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

# demande de stage ecole

def show_ecole(self):

if 'ecole' not in self.pages:

self.pages['ecole'] = ecole()

self.stacked.addWidget(self.pages['ecole'])

self.stacked.setCurrentWidget(self.pages['ecole'])

# demande stage immersion

def show_immersion(self):

if 'immersion' not in self.pages:

self.pages['immersion'] = immersion()

self.stacked.addWidget(self.pages['immersion'])

self.stacked.setCurrentWidget(self.pages['immersion'])

# demande stage renforcement

def show_renforcement(self):

if 'renforcement' not in self.pages:

self.pages['renforcement'] = renforcement()

self.stacked.addWidget(self.pages['renforcement'])

self.stacked.setCurrentWidget(self.pages['renforcement'])

# enregistrement de stagiaires

def show_enregistrement_stagiaire_page(self):

self.setWindowTitle("Type de Demande")
current_index = self.stacked.currentIndex()

history.append(current_index)

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.enregistrement_stagiaire_page = QWidget(self)

self.stacked.addWidget(self.enregistrement_stagiaire_page)

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

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)

# enregistrement stagiaire ecole

def enre_stagiaire_ecole(self):

if 'stagiaire_ecole' not in self.pages:

self.pages['stagiaire_ecole'] = enregistrement_stagiaire_ecole()

self.stacked.addWidget(self.pages['stagiaire_ecole'])

self.stacked.setCurrentWidget(self.pages['stagiaire_ecole'])

# enregistrement stagiaire immersion

def enre_stagiaire_immersion(self):

if 'stagiaire_immersion' not in self.pages:

self.pages['stagiaire_immersion'] = enregistrement_stagiaire_immersion()

self.stacked.addWidget(self.pages['stagiaire_immersion'])

self.stacked.setCurrentWidget(self.pages['stagiaire_immersion'])

# enregistrement stagiaire renforcement

def enre_stagiaire_renforcement(self):

if 'stagiaire_renforcement' not in self.pages:

self.pages['stagiaire_renforcement'] = enregistrement_stagiaire_renforcement()

self.stacked.addWidget(self.pages['stagiaire_renforcement'])

self.stacked.setCurrentWidget(self.pages['stagiaire_renforcement'])

# les fonctions de la page stagiaire

def show_stagiaire_page(self):

self.setWindowTitle("Gestion des stagiaires")

current_index = self.stacked.currentIndex()

history.append(current_index)
self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.stagiaire_page = QWidget(self)

self.stacked.addWidget(self.stagiaire_page)

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

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)

self.stacked.addWidget(self.stagiaire_page)

self.stacked.setCurrentWidget(self.stagiaire_page)
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):

if 'stagiaires' not in self.pages:

self.pages['stagiaires'] = stagiaires_ecole()

self.stacked.addWidget(self.pages['stagiaires'])

self.stacked.setCurrentWidget(self.pages['stagiaires'])

# gestion des stagiaires immersion

def showimmersion(self):

if 'stagiaires' not in self.pages:

self.pages['stagiaires'] = stagiaires_immersion()

self.stacked.addWidget(self.pages['stagiaires'])

self.stacked.setCurrentWidget(self.pages['stagiaires'])

# gestion des stagiaires renforcement

def showrenforcement(self):

if 'stagiaires' not in self.pages:

self.pages['stagiaires'] = stagiaires_renforcement()

self.stacked.addWidget(self.pages['stagiaires'])

self.stacked.setCurrentWidget(self.pages['stagiaires'])

def go_back(self):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)
else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

def show_maitre_page(self):

if 'maitre' not in self.pages:

self.pages['maitre'] = MaitrePage()

self.stacked.addWidget(self.pages['maitre'])

self.stacked.setCurrentWidget(self.pages['maitre'])

def show_validation_page(self):

if 'validation' not in self.pages:

self.pages['validation'] = ValidationPage()

self.stacked.addWidget(self.pages['validation'])

self.stacked.setCurrentWidget(self.pages['validation'])

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()

# classe d'enregistrement des demandes de stage ecole

class ecole(QMainWindow):

def __init__(self):

super().__init__()

self.init_ui()

def init_ui(self):

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

current_index = self.stacked.currentIndex()

history.append(current_index)

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.EcolePage = QWidget()

self.stacked.addWidget(self.EcolePage)

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

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 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("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):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

# classe d'enregistrement des demandes de stage immersion

class immersion(QMainWindow):

def __init__(self):

super().__init__()
self.init_ui()

def init_ui(self):

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

current_index = self.stacked.currentIndex()

history.append(current_index)

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.immersionPage = QWidget()

self.stacked.addWidget(self.immersionPage)

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

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):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

# classe d'enregistrement des demandes de stage renforcement

class renforcement(QMainWindow):

def __init__(self):

super().__init__()

self.init_ui()

def init_ui(self):

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

current_index = self.stacked.currentIndex()

history.append(current_index)

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.renforcementPage = QWidget()
self.stacked.addWidget(self.renforcementPage)

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

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):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

# classe d'enregistrement des stagiaires ecole

class enregistrement_stagiaire_ecole (QMainWindow):

def __init__(self):

super().__init__()

self.initUI()

self.show_stagiaire_ecole()

def initUI(self):

self.setWindowTitle("Stagiaires - Stage ecole")

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.show_enregistrement_stagiaire_ecole_page = QWidget(self)

self.stacked.addWidget(self.show_enregistrement_stagiaire_ecole_page)
self.form_frame = QtWidgets.QFrame(self.show_enregistrement_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;

""")

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):


current_index = self.stacked.currentIndex()

history.append(current_index)

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")

current_index = self.stacked.currentIndex()

history.append(current_index)

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")

current_index = self.stacked.currentIndex()

history.append(current_index)

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.nouveau_Page = QWidget()

self.stacked.addWidget(self.nouveau_Page)

self.form_frame = QtWidgets.QFrame(self.nouveau_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,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):

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!")

finally:

connexion.close()

def go_back(self):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

# classe d'enregistrement des stagiaires immersion

class enregistrement_stagiaire_immersion (QMainWindow):

def __init__(self):

super().__init__()

self.initUI()

self.show_stagiaire_immersion()

def initUI(self):

self.setWindowTitle("Stagiaires - Stage immersion")

self.stacked = QStackedWidget()

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

self.stacked.addWidget(self.show_enregistrement_stagiaire_immersion_page)

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

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):

current_index = self.stacked.currentIndex()

history.append(current_index)

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")

current_index = self.stacked.currentIndex()

history.append(current_index)

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.stagiaire_immersion_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,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")

current_index = self.stacked.currentIndex()

history.append(current_index)

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.nouveau_Page = QWidget()

self.stacked.addWidget(self.nouveau_Page)

self.form_frame = QtWidgets.QFrame(self.nouveau_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,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):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

# classe d'enregistrement des stagiaires renforcement

class enregistrement_stagiaire_renforcement (QMainWindow):

def __init__(self):

super().__init__()

self.initUI()

self.show_stagiaire_renforcement()

def initUI(self):

self.setWindowTitle("Stagiaires - Stage renforcement")

self.stacked = QStackedWidget()

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

self.stacked.addWidget(self.show_enregistrement_stagiaire_renforcement_page)

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

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):

current_index = self.stacked.currentIndex()

history.append(current_index)

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")

current_index = self.stacked.currentIndex()

history.append(current_index)

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.stagiaire_renforcement_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,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.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.diplome_input = QLineEdit(self.form_frame)

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

self.diplome_input.setText(diplome)

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 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.setWindowTitle("Formulaire du nouveau stagiaire")

current_index = self.stacked.currentIndex()

history.append(current_index)

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.nouveau_Page = QWidget()

self.stacked.addWidget(self.nouveau_Page)

self.form_frame = QtWidgets.QFrame(self.nouveau_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,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.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_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):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")


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.show_enregistrement_stagiaire_renforcement_page = QWidget(self)

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

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 stagiaires_ecole(QMainWindow):

def __init__(self):

super().__init__()

self.initUi()

self.show_stagiaire_ecole()

def initUi(self):

self.setWindowTitle("Stagiaires ecole")

self.stacked = QStackedWidget()

self.setCentralWidget(self.stacked)

self.stagiaire_ecole_page = QWidget(self)

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;
""")

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):

current_index = self.stacked.currentIndex()

history.append(current_index)

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):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

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.stagiaire_immersion_page = QWidget(self)

self.stacked.addWidget(self.stagiaire_immersion_page)

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

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):

current_index = self.stacked.currentIndex()

history.append(current_index)

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):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

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.stagiaire_renforcement_page = QWidget(self)

self.stacked.addWidget(self.stagiaire_renforcement_page)

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

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):

current_index = self.stacked.currentIndex()

history.append(current_index)
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):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

class MaitrePage(QWidget):

def __init__(self):

super().__init__()

layout = QVBoxLayout(self)
label = QLabel("Maitre de Stage des informations")

layout.addWidget(label)

back_button = QPushButton("Retour")

back_button.clicked.connect(self.go_back)

layout.addWidget(back_button)

def go_back(self):

if len (history) > 0:

previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

class ValidationPage(QWidget):

def __init__(self):

super().__init__()

layout = QVBoxLayout(self)

label = QLabel("Validation des stagiaires")

layout.addWidget(label)

back_button = QPushButton("Retour")

back_button.clicked.connect(self.go_back)

layout.addWidget(back_button)

def go_back(self):

if len (history) > 0:


previous_page_index = history.pop()

self.stacked.setCurrentIndex(previous_page_index)

else:

QMessageBox.warning(self,"Erreur","Aucune page precedente")

if __name__ == "__main__":

app = QApplication([])

main_window = Login()

main_window.showMaximized()

app.exec_()

You might also like