Ecole 4
Ecole 4
import sys
import os
import subprocess
import platform
import mysql.connector
import fitz
def creer_connexion():
try:
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)
layout.addWidget(label)
class Login(QMainWindow):
def __init__(self):
super().__init__()
# Configuration de la fenêtre
self.setWindowTitle("Gestion d'Inventaire")
self.setStyleSheet("background-color: #FF00FF;")
self.stacked = QStackedWidget()
self.setCentralWidget(self.stacked)
# Page de connexion
self.login_page = QWidget()
self.stacked.addWidget(self.login_page)
self.form_frame = QtWidgets.QFrame(self.login_page)
self.form_frame.setStyleSheet("""
background-color: rgba(255, 255, 255, 0.5);
border-radius: 15px;
""")
self.title.setFont(QtGui.QFont("Arial", 16))
self.username_input = QLineEdit(self.form_frame)
self.password_input = QLineEdit(self.form_frame)
self.password_input.setEchoMode(QLineEdit.Password)
self.resultat_label.setStyleSheet("color: red;")
# Bouton de connexion
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;")
self.menu_layout = QVBoxLayout(self.side_menu)
self.enregistrement.setStyleSheet("background-color: #FB00BF;")
self.enregistrement.clicked.connect(self.show_enregistrement_page)
self.menu_layout.addWidget(self.enregistrement)
self.stagiaire.setStyleSheet("background-color: #FB00BF;")
self.stagiaire.clicked.connect(self.show_stagiaire_page)
self.menu_layout.addWidget(self.stagiaire)
self.maitre.clicked.connect(self.show_maitre_page)
self.menu_layout.addWidget(self.maitre)
self.validation.clicked.connect(self.show_validation_page)
self.menu_layout.addWidget(self.validation)
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()
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()
resultat = curseur.fetchone()
connexion.close()
if resultat:
self.pages['accueil']= Accueil()
self.stacked.addWidget(self.pages['accueil'])
self.stacked.setCurrentWidget(self.pages['accueil'])
self.toggle_button.show()
else:
def show_enregistrement_page(self):
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.setStyleSheet("""
border-radius: 15px;
""")
self.demande_stage_button.setGeometry(50,100,500,500)
self.demande_stage_button.clicked.connect(self.show_demande_stage_page)
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)
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)
border-radius: 15px;
""")
self.stage_ecole_button.setGeometry(50,120,350,350)
self.stage_ecole_button.clicked.connect(self.show_ecole)
self.immersion_button.setGeometry(425,120,350,350)
self.immersion_button.clicked.connect(self.show_immersion)
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):
self.stacked.setCurrentIndex(previous_page_index)
else:
def show_ecole(self):
self.pages['ecole'] = ecole()
self.stacked.addWidget(self.pages['ecole'])
self.stacked.setCurrentWidget(self.pages['ecole'])
def show_immersion(self):
self.pages['immersion'] = immersion()
self.stacked.addWidget(self.pages['immersion'])
self.stacked.setCurrentWidget(self.pages['immersion'])
def show_renforcement(self):
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.setStyleSheet("""
border-radius: 15px;
""")
self.stagiaire_ecole_button.setGeometry(50,120,350,350)
self.stagiaire_ecole_button.clicked.connect(self.enre_stagiaire_ecole)
self.stagiaire_immersion_button.setGeometry(425,120,350,350)
self.stagiaire_immersion_button.clicked.connect(self.enre_stagiaire_immersion)
self.stagiaire_renforcement_button.setGeometry(800,120,350,350)
self.stagiaire_renforcement_button.clicked.connect(self.enre_stagiaire_renforcement)
back_button = QPushButton("Retour",self.form_frame)
back_button.setGeometry(1000,550,100,55)
back_button.clicked.connect(self.go_back)
def enre_stagiaire_ecole(self):
self.pages['stagiaire_ecole'] = enregistrement_stagiaire_ecole()
self.stacked.addWidget(self.pages['stagiaire_ecole'])
self.stacked.setCurrentWidget(self.pages['stagiaire_ecole'])
def enre_stagiaire_immersion(self):
self.pages['stagiaire_immersion'] = enregistrement_stagiaire_immersion()
self.stacked.addWidget(self.pages['stagiaire_immersion'])
self.stacked.setCurrentWidget(self.pages['stagiaire_immersion'])
def enre_stagiaire_renforcement(self):
self.pages['stagiaire_renforcement'] = enregistrement_stagiaire_renforcement()
self.stacked.addWidget(self.pages['stagiaire_renforcement'])
self.stacked.setCurrentWidget(self.pages['stagiaire_renforcement'])
def show_stagiaire_page(self):
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.setStyleSheet("""
border-radius: 15px;
""")
self.stagiaire_ecole_button.setGeometry(50,120,350,350)
self.stagiaire_ecole_button.clicked.connect(self.showecole)
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)
def showecole(self):
self.pages['stagiaires'] = stagiaires_ecole()
self.stacked.addWidget(self.pages['stagiaires'])
self.stacked.setCurrentWidget(self.pages['stagiaires'])
def showimmersion(self):
self.pages['stagiaires'] = stagiaires_immersion()
self.stacked.addWidget(self.pages['stagiaires'])
self.stacked.setCurrentWidget(self.pages['stagiaires'])
def showrenforcement(self):
self.pages['stagiaires'] = stagiaires_renforcement()
self.stacked.addWidget(self.pages['stagiaires'])
self.stacked.setCurrentWidget(self.pages['stagiaires'])
def go_back(self):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
def show_maitre_page(self):
self.pages['maitre'] = MaitrePage()
self.stacked.addWidget(self.pages['maitre'])
self.stacked.setCurrentWidget(self.pages['maitre'])
def show_validation_page(self):
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()
class ecole(QMainWindow):
def __init__(self):
super().__init__()
self.init_ui()
def init_ui(self):
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.setStyleSheet("""
border-radius: 15px;
""")
self.infop.setFont(QtGui.QFont("Arial", 16))
self.name_input = QLineEdit(self.form_frame)
self.name_input.setPlaceholderText("nom : ")
self.surname_input = QLineEdit(self.form_frame)
self.surname_input.setPlaceholderText("prenom : ")
self.dob_input = QDateEdit(self.form_frame)
self.dob_input.setCalendarPopup (True)
self.lieu_input = QLineEdit(self.form_frame)
self.address_input = QLineEdit(self.form_frame)
self.address_input.setPlaceholderText("addresse : ")
self.phone_input = QLineEdit(self.form_frame)
self.email_input = QLineEdit(self.form_frame)
self.infoa.setFont(QtGui.QFont("Arial", 16))
self.school_input = QLineEdit(self.form_frame)
self.level_input = QLineEdit(self.form_frame)
self.major_input = QLineEdit(self.form_frame)
self.contact_input = QLineEdit(self.form_frame)
self.infodoc.setFont(QtGui.QFont("Arial", 16))
self.cv_button.setGeometry(35,440,250,125)
self.cv_button.clicked.connect(self.upload_cv)
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.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.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.hide()
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()
if file_name:
self.cv_button.setText(file_name)
def upload_letter(self):
options = QFileDialog.Options()
if file_name:
self.letter_button.setText(file_name)
def upload_photo(self):
options = QFileDialog.Options()
if file_name :
try:
pixmap = QPixmap(file_name)
if pixmap.isNull():
return
self.photo_label.setPixmap(pixmap)
self.photo_label.show()
self.photo_button.hide()
self.photo_path = file_name
except Exception as e :
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()
photo_file = getattr(self,'photo_path',None)
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()
# except Error as e:
finally:
connexion.close()
def go_back(self):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
class immersion(QMainWindow):
def __init__(self):
super().__init__()
self.init_ui()
def init_ui(self):
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.setStyleSheet("""
border-radius: 15px;
""")
self.title.setFont(QtGui.QFont("Arial", 16))
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.setPlaceholderText("prenom : ")
self.dob_input = QDateEdit(self.form_frame)
self.dob_input.setCalendarPopup (True)
self.lieu_input = QLineEdit(self.form_frame)
self.address_input = QLineEdit(self.form_frame)
self.address_input.setPlaceholderText("addresse : ")
self.phone_input = QLineEdit(self.form_frame)
self.email_input = QLineEdit(self.form_frame)
self.infoa.setFont(QtGui.QFont("Arial", 16))
self.school_input = QLineEdit(self.form_frame)
self.level_input = QLineEdit(self.form_frame)
self.contact_input = QLineEdit(self.form_frame)
self.infodoc.setFont(QtGui.QFont("Arial", 16))
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.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.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.hide()
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()
if file_name:
self.cv_button.setText(file_name)
def upload_letter(self):
options = QFileDialog.Options()
if file_name:
self.letter_button.setText(file_name)
def upload_photo(self):
options = QFileDialog.Options()
if file_name :
try:
pixmap = QPixmap(file_name)
if pixmap.isNull():
return
self.photo_label.setPixmap(pixmap)
self.photo_label.show()
self.photo_button.hide()
self.photo_path = file_name
except Exception as 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()
photo_file = getattr(self,'photo_path',None)
else:
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
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()
except Error as e:
QMessageBox.warning(self,"Erreur",f"Erreur lors de l'enregistrement : {e}")
finally:
connexion.close()
def go_back(self):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
class renforcement(QMainWindow):
def __init__(self):
super().__init__()
self.init_ui()
def init_ui(self):
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.setStyleSheet("""
border-radius: 15px;
""")
self.title.setFont(QtGui.QFont("Arial", 16))
self.infop.setFont(QtGui.QFont("Arial", 16))
self.name_input = QLineEdit(self.form_frame)
self.name_input.setPlaceholderText("nom : ")
self.surname_input = QLineEdit(self.form_frame)
self.surname_input.setPlaceholderText("prenom : ")
self.dob_input.setCalendarPopup (True)
self.lieu_input = QLineEdit(self.form_frame)
self.address_input = QLineEdit(self.form_frame)
self.address_input.setPlaceholderText("addresse : ")
self.phone_input = QLineEdit(self.form_frame)
self.email_input = QLineEdit(self.form_frame)
self.infoa.setFont(QtGui.QFont("Arial", 16))
self.school_input = QLineEdit(self.form_frame)
self.major_input = QLineEdit(self.form_frame)
self.contact_input = QLineEdit(self.form_frame)
self.infodoc.setFont(QtGui.QFont("Arial", 16))
self.cv_button.setGeometry(35,440,250,125)
self.cv_button.clicked.connect(self.upload_cv)
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.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.hide()
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()
if file_name:
self.cv_button.setText(file_name)
def upload_letter(self):
options = QFileDialog.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():
return
self.photo_label.setPixmap(pixmap)
self.photo_label.show()
self.photo_button.hide()
self.photo_path = file_name
except Exception as 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()
photo_file = getattr(self,'photo_path',None)
else:
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
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()
except Error as e:
finally:
connexion.close()
def go_back(self):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
def __init__(self):
super().__init__()
self.initUI()
self.show_stagiaire_ecole()
def initUI(self):
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.setStyleSheet("""
border-radius: 15px;
""")
def show_stagiaire_ecole(self):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
stagiaires = curseur.fetchall()
y = 50
self.create_stagiaire_ecole_bloc(id,nom,prenom,telephone , photo,statut,y)
y+=175
except Error as e:
finally:
connexion.close()
history.append(current_index)
frame = QFrame(self)
frame.setGeometry(140,y,550,180)
frame.setFrameShape(QFrame.Box)
nom_label.setGeometry(180,10,300,50)
nom_label.setFont(QtGui.QFont("Arial", 16))
prenom_label.setGeometry(180,40,300,50)
prenom_label.setFont(QtGui.QFont("Arial", 16))
telephone_label.setGeometry(180,70,300,50)
telephone_label.setFont(QtGui.QFont("Arial", 16))
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)
def show_stagiaire_ecole_form(self,id_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.setStyleSheet("""
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.setFont(QtGui.QFont("Arial", 16))
self.infop.setFont(QtGui.QFont("Arial", 16))
self.name_input = QLineEdit(self.form_frame)
self.name_input.setText(nom)
self.surname_input = QLineEdit(self.form_frame)
self.surname_input.setText(prenom)
self.dob_input = QDateEdit(self.form_frame)
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.setText(lieu_naissance)
self.address_input = QLineEdit(self.form_frame)
self.address_input.setText(adresse)
self.phone_input = QLineEdit(self.form_frame)
self.phone_input.setText(telephone)
self.email_input = QLineEdit(self.form_frame)
self.email_input.setText(adresse_email)
self.infoa = QLabel("PARCOURS ACADEMIQUE :", self.form_frame)
self.infoa.setFont(QtGui.QFont("Arial", 16))
self.school_input = QLineEdit(self.form_frame)
self.school_input.setText(etablissement)
self.level_input = QLineEdit(self.form_frame)
self.level_input.setText(diplome_prepa)
self.major_input = QLineEdit(self.form_frame)
self.major_input.setText(filiere)
self.contact_input = QLineEdit(self.form_frame)
self.contact_input.setText(contact_urgence)
self.infodoc.setFont(QtGui.QFont("Arial", 16))
self.cv_file = cv_file
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.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.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)
photo_pixmap = QPixmap(photo).scaled(180,150,Qt.KeepAspectRatio)
self.photo_view = QLabel(self)
self.photo_view.setPixmap(photo_pixmap)
self.statut_input = QLineEdit(self.form_frame)
self.statut_input.setText(statut)
accept_button = QPushButton("Accepter",self.form_frame)
accept_button.setGeometry(800,460,150,35)
refus_button = QPushButton("refusé",self.form_frame)
refus_button.setGeometry(800,660,150,35)
back_button.setGeometry(1000,550,100,55)
back_button.clicked.connect(self.go_back)
except Error as 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)
subprocess.call(('xdg*open',self.cv_file))
else:
except Exception as e :
else:
else:
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
connexion.commit()
self.nouveau_stagiaire(id_stagiaire)
finally:
connexion.close()
def refus_stagiaire(self,id_stagiaire):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
connexion.commit()
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.setStyleSheet("""
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.setFont(QtGui.QFont("Arial", 16))
self.infop.setFont(QtGui.QFont("Arial", 16))
self.name_input = QLineEdit(self.form_frame)
self.name_input.setText(nom)
self.surname_input = QLineEdit(self.form_frame)
self.surname_input.setText(prenom)
self.dob_input = QDateEdit(self.form_frame)
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.setText(lieu_naissance)
self.address_input = QLineEdit(self.form_frame)
self.address_input.setText(adresse)
self.phone_input = QLineEdit(self.form_frame)
self.phone_input.setText(telephone)
self.email_input = QLineEdit(self.form_frame)
self.email_input.setText(adresse_email)
self.infoa.setFont(QtGui.QFont("Arial", 16))
self.contact_input = QLineEdit(self.form_frame)
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.siege_input = QLineEdit(self.form_frame)
self.date_debut_input = QDateEdit(self.form_frame)
self.date_debut_input.setCalendarPopup (True)
self.date_fin_input = QDateEdit(self.form_frame)
self.date_fin_input.setCalendarPopup (True)
self.date_debut_input.dateChanged.connect(self.update_date_fin)
self.photo_label = QLabel(self.form_frame)
self.statut_input = QLineEdit(self.form_frame)
self.statut_input.setText("stagiaire")
self.cv_file = cv_file
if cv_file:
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:
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()
else:
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
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):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
def __init__(self):
super().__init__()
self.initUI()
self.show_stagiaire_immersion()
def initUI(self):
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.setStyleSheet("""
border-radius: 15px;
""")
def show_stagiaire_immersion(self):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
stagiaires = curseur.fetchall()
y = 50
self.create_stagiaire_immersion_bloc(id,nom,prenom,telephone , photo,statut,y)
y+=175
except Error as e:
connexion.close()
current_index = self.stacked.currentIndex()
history.append(current_index)
frame = QFrame(self)
frame.setGeometry(140,y,550,180)
frame.setFrameShape(QFrame.Box)
nom_label.setGeometry(180,10,300,50)
nom_label.setFont(QtGui.QFont("Arial", 16))
prenom_label.setGeometry(180,40,300,50)
prenom_label.setFont(QtGui.QFont("Arial", 16))
telephone_label.setGeometry(180,70,300,50)
telephone_label.setFont(QtGui.QFont("Arial", 16))
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)
def show_stagiaire_immersion_form(self,id_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.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.setFont(QtGui.QFont("Arial", 16))
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.setText(prenom)
self.dob_input = QDateEdit(self.form_frame)
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.setText(lieu_naissance)
self.address_input = QLineEdit(self.form_frame)
self.address_input.setText(adresse)
self.phone_input = QLineEdit(self.form_frame)
self.phone_input.setText(telephone)
self.email_input = QLineEdit(self.form_frame)
self.infoa.setFont(QtGui.QFont("Arial", 16))
self.school_input = QLineEdit(self.form_frame)
self.school_input.setText(etablissement)
self.level_input = QLineEdit(self.form_frame)
self.level_input.setText(niveau)
self.contact_input = QLineEdit(self.form_frame)
self.contact_input.setText(contact_urgence)
self.infodoc.setFont(QtGui.QFont("Arial", 16))
self.cv_file = cv_file
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.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.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)
photo_pixmap = QPixmap(photo_file).scaled(180,150,Qt.KeepAspectRatio)
self.photo_view = QLabel(self)
self.photo_view.setPixmap(photo_pixmap)
self.statut_input = QLineEdit(self.form_frame)
self.statut_input.setText(statut)
accept_button = QPushButton("Accepter",self.form_frame)
accept_button.setGeometry(800,460,150,35)
refus_button = QPushButton("refusé",self.form_frame)
refus_button.setGeometry(800,660,150,35)
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:
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)
subprocess.call(('xdg*open',self.cv_file))
else:
except Exception as e :
else:
else:
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
connexion.commit()
self.nouveau_stagiaire(id_stagiaire)
finally:
connexion.close()
def refus_stagiaire(self,id_stagiaire):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
connexion.commit()
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.setStyleSheet("""
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.setFont(QtGui.QFont("Arial", 16))
self.infop.setFont(QtGui.QFont("Arial", 16))
self.name_input = QLineEdit(self.form_frame)
self.name_input.setText(nom)
self.surname_input = QLineEdit(self.form_frame)
self.surname_input.setText(prenom)
self.dob_input = QDateEdit(self.form_frame)
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.setText(lieu_naissance)
self.address_input = QLineEdit(self.form_frame)
self.address_input.setText(adresse)
self.phone_input = QLineEdit(self.form_frame)
self.phone_input.setText(telephone)
self.email_input = QLineEdit(self.form_frame)
self.email_input.setText(adresse_email)
self.infoa.setFont(QtGui.QFont("Arial", 16))
self.contact_input = QLineEdit(self.form_frame)
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.siege_input = QLineEdit(self.form_frame)
self.date_debut_input = QDateEdit(self.form_frame)
self.date_debut_input.setCalendarPopup (True)
self.date_fin_input = QDateEdit(self.form_frame)
self.date_fin_input.setCalendarPopup (True)
self.date_debut_input.dateChanged.connect(self.update_date_fin)
self.photo_label = QLabel(self.form_frame)
self.statut_input = QLineEdit(self.form_frame)
self.statut_input.setText("stagiaire")
self.cv_file = cv_file
if cv_file:
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:
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()
else:
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
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()
finally:
connexion.close()
def go_back(self):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
def __init__(self):
super().__init__()
self.initUI()
self.show_stagiaire_renforcement()
def initUI(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.setStyleSheet("""
border-radius: 15px;
""")
def show_stagiaire_renforcement(self):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
stagiaires = curseur.fetchall()
y = 50
self.create_stagiaire_renforcement_bloc(id,nom,prenom,telephone , photo,statut,y)
y+=175
except Error as e:
connexion.close()
current_index = self.stacked.currentIndex()
history.append(current_index)
frame = QFrame(self)
frame.setGeometry(140,y,550,180)
frame.setFrameShape(QFrame.Box)
nom_label.setGeometry(180,10,300,50)
nom_label.setFont(QtGui.QFont("Arial", 16))
prenom_label.setGeometry(180,40,300,50)
prenom_label.setFont(QtGui.QFont("Arial", 16))
telephone_label.setGeometry(180,70,300,50)
telephone_label.setFont(QtGui.QFont("Arial", 16))
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)
def show_stagiaire_renforcement_form(self,id_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)
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.setFont(QtGui.QFont("Arial", 16))
self.infop.setFont(QtGui.QFont("Arial", 16))
self.name_input = QLineEdit(self.form_frame)
self.name_input.setText(nom)
self.surname_input = QLineEdit(self.form_frame)
self.surname_input.setText(prenom)
self.dob_input = QDateEdit(self.form_frame)
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.setText(lieu_naissance)
self.address_input = QLineEdit(self.form_frame)
self.address_input.setText(adresse)
self.phone_input = QLineEdit(self.form_frame)
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.setFont(QtGui.QFont("Arial", 16))
self.school_input = QLineEdit(self.form_frame)
self.school_input.setText(etablissement)
self.diplome_input = QLineEdit(self.form_frame)
self.diplome_input.setText(diplome)
self.major_input = QLineEdit(self.form_frame)
self.major_input.setText(filiere)
self.contact_input = QLineEdit(self.form_frame)
self.contact_input.setText(contact_urgence)
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.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.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)
photo_pixmap = QPixmap(photo).scaled(180,150,Qt.KeepAspectRatio)
self.photo_view = QLabel(self)
self.photo_view.setPixmap(photo_pixmap)
self.statut_input = QLineEdit(self.form_frame)
self.statut_input.setText(statut)
accept_button = QPushButton("Accepter",self.form_frame)
accept_button.setGeometry(800,460,150,35)
refus_button.setGeometry(800,660,150,35)
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:
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)
subprocess.call(('xdg*open',self.cv_file))
else:
except Exception as e :
else:
def accept_stagiaire(self,id_stagiaire):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
connexion.commit()
self.nouveau_stagiaire(id_stagiaire)
finally:
connexion.close()
def refus_stagiaire(self,id_stagiaire):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
connexion.commit()
finally:
connexion.close()
def nouveau_stagiaire(self,id_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.setStyleSheet("""
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.setFont(QtGui.QFont("Arial", 16))
self.infop.setFont(QtGui.QFont("Arial", 16))
self.name_input = QLineEdit(self.form_frame)
self.name_input.setText(nom)
self.surname_input = QLineEdit(self.form_frame)
self.surname_input.setText(prenom)
self.dob_input = QDateEdit(self.form_frame)
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.setText(lieu_naissance)
self.address_input = QLineEdit(self.form_frame)
self.address_input.setText(adresse)
self.phone_input = QLineEdit(self.form_frame)
self.phone_input.setText(telephone)
self.email_input = QLineEdit(self.form_frame)
self.email_input.setText(adresse_email)
self.infoa.setFont(QtGui.QFont("Arial", 16))
self.contact_input = QLineEdit(self.form_frame)
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.service_input = QLineEdit(self.form_frame)
self.siege_input = QLineEdit(self.form_frame)
self.date_debut_input = QDateEdit(self.form_frame)
self.date_debut_input.setCalendarPopup (True)
self.date_fin_input = QDateEdit(self.form_frame)
self.date_fin_input.setCalendarPopup (True)
self.date_debut_input.dateChanged.connect(self.update_date_fin)
self.photo_label = QLabel(self.form_frame)
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.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:
finally:
connexion.close()
def go_back(self):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
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()
else:
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
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()
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.setStyleSheet("""
border-radius: 15px;
""")
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:
connexion = creer_connexion
curseur = connexion.cursor()
result = curseur.fetchone()
connexion.close()
if result:
cv_file = result[0]
return cv_file
else:
return None
except Exception as e:
return None
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
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.setStyleSheet("""
border-radius: 15px;
""")
def show_stagiaire_ecole(self):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
stagiaires = curseur.fetchall()
y = 50
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:
finally:
connexion.close()
current_index = self.stacked.currentIndex()
history.append(current_index)
frame = QFrame(self)
frame.setGeometry(140,y,670,180)
frame.setFrameShape(QFrame.Box)
nom_label.setGeometry(140,10,250,40)
nom_label.setFont(QtGui.QFont("Arial", 14))
prenom_label.setGeometry(140,40,250,40)
prenom_label.setFont(QtGui.QFont("Arial", 14))
telephone_label.setGeometry(140,70,250,40)
telephone_label.setFont(QtGui.QFont("Arial", 14))
service_label.setGeometry(140,100,250,40)
service_label.setFont(QtGui.QFont("Arial", 14))
siege_label.setGeometry(140,130,250,40)
siege_label.setFont(QtGui.QFont("Arial", 14))
date_debut_label.setGeometry(360,40,300,40)
date_debut_label.setFont(QtGui.QFont("Arial", 14))
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)
def go_back(self):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
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.setStyleSheet("""
border-radius: 15px;
""")
def show_stagiaire_immersion(self):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
stagiaires = curseur.fetchall()
y = 50
for stagiaire in stagiaires:
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:
finally:
connexion.close()
current_index = self.stacked.currentIndex()
history.append(current_index)
frame = QFrame(self)
frame.setGeometry(140,y,670,180)
frame.setFrameShape(QFrame.Box)
nom_label.setGeometry(140,10,250,40)
nom_label.setFont(QtGui.QFont("Arial", 14))
prenom_label.setGeometry(140,40,250,40)
prenom_label.setFont(QtGui.QFont("Arial", 14))
telephone_label.setFont(QtGui.QFont("Arial", 14))
service_label.setGeometry(140,100,250,40)
service_label.setFont(QtGui.QFont("Arial", 14))
siege_label.setGeometry(140,130,250,40)
siege_label.setFont(QtGui.QFont("Arial", 14))
date_debut_label.setGeometry(360,40,300,40)
date_debut_label.setFont(QtGui.QFont("Arial", 14))
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):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
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.setStyleSheet("""
""")
def show_stagiaire_renforcement(self):
connexion = creer_connexion()
if connexion:
try:
curseur = connexion.cursor()
stagiaires = curseur.fetchall()
y = 50
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:
finally:
connexion.close()
current_index = self.stacked.currentIndex()
history.append(current_index)
frame = QFrame(self)
frame.setGeometry(140,y,670,180)
frame.setFrameShape(QFrame.Box)
nom_label.setGeometry(140,10,250,40)
nom_label.setFont(QtGui.QFont("Arial", 14))
prenom_label.setGeometry(140,40,250,40)
prenom_label.setFont(QtGui.QFont("Arial", 14))
telephone_label.setGeometry(140,70,250,40)
telephone_label.setFont(QtGui.QFont("Arial", 14))
service_label.setGeometry(140,100,250,40)
service_label.setFont(QtGui.QFont("Arial", 14))
siege_label.setGeometry(140,130,250,40)
siege_label.setFont(QtGui.QFont("Arial", 14))
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):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
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):
previous_page_index = history.pop()
self.stacked.setCurrentIndex(previous_page_index)
else:
class ValidationPage(QWidget):
def __init__(self):
super().__init__()
layout = QVBoxLayout(self)
layout.addWidget(label)
back_button = QPushButton("Retour")
back_button.clicked.connect(self.go_back)
layout.addWidget(back_button)
def go_back(self):
self.stacked.setCurrentIndex(previous_page_index)
else:
if __name__ == "__main__":
app = QApplication([])
main_window = Login()
main_window.showMaximized()
app.exec_()