Initialisation du projet de gestion des inventaires multi-sites
This commit is contained in:
4
.env
Normal file
4
.env
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
DB_HOST=54.36.188.119
|
||||||
|
DB_USER=michel
|
||||||
|
DB_PASSWORD=#SO2&1nf%mZ@jfh
|
||||||
|
DB_NAME=Commun
|
||||||
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
10
.idea/Ratio & inventaires.iml
generated
Normal file
10
.idea/Ratio & inventaires.iml
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.13 (Ratio & inventaires)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
8
.idea/dictionaries/project.xml
generated
Normal file
8
.idea/dictionaries/project.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="project">
|
||||||
|
<words>
|
||||||
|
<w>acces</w>
|
||||||
|
<w>curdate</w>
|
||||||
|
</words>
|
||||||
|
</dictionary>
|
||||||
|
</component>
|
||||||
19
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
19
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredErrors">
|
||||||
|
<list>
|
||||||
|
<option value="N812" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoredIdentifiers">
|
||||||
|
<list>
|
||||||
|
<option value="paho.mqtt.client.MQTTException" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</inspection_tool>
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.13 (Ratio & inventaires)" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Ratio & inventaires.iml" filepath="$PROJECT_DIR$/.idea/Ratio & inventaires.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
BIN
Excel/Commun.xlsm
Normal file
BIN
Excel/Commun.xlsm
Normal file
Binary file not shown.
1
Excel/login_utilisateur.txt
Normal file
1
Excel/login_utilisateur.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Sabrina
|
||||||
1
Excel/site_selectionne.txt
Normal file
1
Excel/site_selectionne.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Saclay
|
||||||
81
connexion.py
Normal file
81
connexion.py
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
import tkinter as tk
|
||||||
|
from tkinter import messagebox
|
||||||
|
import mysql.connector
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
# Charger les variables d'environnement
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
DB_HOST = os.getenv("DB_HOST")
|
||||||
|
DB_USER = os.getenv("DB_USER")
|
||||||
|
DB_PASSWORD = os.getenv("DB_PASSWORD")
|
||||||
|
DB_NAME = os.getenv("DB_NAME")
|
||||||
|
|
||||||
|
|
||||||
|
def ouvrir_excel(site, login):
|
||||||
|
dossier_excel = os.path.join(os.path.dirname(__file__), "excel")
|
||||||
|
chemin_excel = os.path.join(dossier_excel, "Commun.xlsm")
|
||||||
|
subprocess.Popen(["start", chemin_excel], shell=True)
|
||||||
|
|
||||||
|
# Écrit le nom du site
|
||||||
|
with open(os.path.join(dossier_excel, "site_selectionne.txt"), "w") as f:
|
||||||
|
f.write(site)
|
||||||
|
|
||||||
|
# Écrit le nom de l'utilisateur connecté
|
||||||
|
with open(os.path.join(dossier_excel, "login_utilisateur.txt"), "w") as f:
|
||||||
|
f.write(login)
|
||||||
|
os.chdir(dossier_excel) # On se place dans le dossier pour lancer Excel
|
||||||
|
subprocess.Popen(["start", "Commun.xlsm"], shell=True)
|
||||||
|
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
|
def verifier_connexion():
|
||||||
|
login = entry_login.get()
|
||||||
|
mdp = entry_mdp.get()
|
||||||
|
|
||||||
|
try:
|
||||||
|
conn = mysql.connector.connect(
|
||||||
|
host=DB_HOST,
|
||||||
|
user=DB_USER,
|
||||||
|
password=DB_PASSWORD,
|
||||||
|
database=DB_NAME
|
||||||
|
)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
|
||||||
|
cursor.execute("SELECT Site, DateExpiration FROM AccesUtilisateurs WHERE NomUtilisateur=%s AND MotDePasse=%s", (login, mdp))
|
||||||
|
result = cursor.fetchone()
|
||||||
|
|
||||||
|
if result:
|
||||||
|
site, expiration = result
|
||||||
|
if expiration and expiration < date.today():
|
||||||
|
messagebox.showerror("Compte expiré", f"Votre compte a expiré le {expiration}.")
|
||||||
|
else:
|
||||||
|
root.destroy()
|
||||||
|
ouvrir_excel(site, login)
|
||||||
|
else:
|
||||||
|
messagebox.showerror("Erreur", "Identifiants invalides.")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
messagebox.showerror("Erreur de connexion", str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Interface utilisateur
|
||||||
|
root = tk.Tk()
|
||||||
|
root.title("Connexion à l'inventaire")
|
||||||
|
|
||||||
|
tk.Label(root, text="Nom d'utilisateur").grid(row=0, column=0)
|
||||||
|
tk.Label(root, text="Mot de passe").grid(row=1, column=0)
|
||||||
|
|
||||||
|
entry_login = tk.Entry(root)
|
||||||
|
entry_mdp = tk.Entry(root, show="*")
|
||||||
|
|
||||||
|
entry_login.grid(row=0, column=1)
|
||||||
|
entry_mdp.grid(row=1, column=1)
|
||||||
|
|
||||||
|
tk.Button(root, text="Connexion", command=verifier_connexion).grid(row=2, columnspan=2, pady=10)
|
||||||
|
|
||||||
|
root.mainloop()
|
||||||
|
|
||||||
6
gitignore.txt
Normal file
6
gitignore.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.env
|
||||||
|
*.txt
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
Reference in New Issue
Block a user