diff --git a/README.md b/README.md
index 4aa85cb..e101154 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,19 @@ Pour les autres fichiers, voir la Documentation.
**Fonctionnement**
------------
+Lors de l'exécution du programme, le menu principal s'affiche. Il est composé de 4 choix : connexion, inscription, opposition et quitter.
+Le choix 1 permet de se connecter, le choix 2 de s'inscrire, le choix 3 de récupérer l'accès à sa carte suspendue et le choix 4 de quitter le programme.
+- Si l'utilisateur se connecte, il est redirigé vers le menu client ou administrateur selon son rôle.
+- Si l'utilisateur s'inscrit, il est redirigé vers le menu principal.
+- Si l'utilisateur récupère l'accès à sa carte suspendue, il est redirigé vers le menu principal.
+- Si l'utilisateur quitte le programme, il est déconnecté et le programme se ferme après la sauvegarde des données.
+
+
+
+Traces d'Exécution
+===============
+
+Trace #1 : https://youtu.be/MiiCGtzQzEM
diff --git a/src/articles.txt b/src/articles.txt
index ec96482..a601d96 100644
--- a/src/articles.txt
+++ b/src/articles.txt
@@ -1,50 +1,50 @@
-1 33.80 1.62 64.50
-2 45.97 1.21 193.57
-3 91.03 0.57 79.36
-4 59.32 0.71 100.99
-5 34.18 1.43 42.44
-6 75.43 2.43 57.86
-7 26.11 2.32 155.97
-8 31.89 0.92 190.94
-9 90.74 0.59 61.87
-10 15.63 1.81 148.95
-11 62.08 1.47 185.78
-12 84.46 2.00 49.14
-13 71.74 0.46 177.15
-14 81.59 1.08 69.27
-15 76.09 1.28 92.17
-16 50.92 2.37 28.14
-17 73.27 1.07 142.01
-18 99.08 2.16 5.51
-19 76.33 1.28 66.87
-20 47.91 1.28 14.79
-21 49.92 0.92 86.80
-22 88.98 1.18 127.61
-23 11.72 1.97 189.64
-24 22.72 0.56 106.91
-25 99.43 1.61 52.19
-26 73.17 1.78 112.36
-27 17.10 2.26 72.91
-28 96.59 2.43 43.50
-29 16.39 1.36 77.74
-30 47.78 1.85 36.03
-31 12.49 0.96 170.42
-32 53.07 0.32 83.83
-33 42.26 0.72 198.57
-34 86.22 1.03 195.66
-35 46.83 0.37 23.29
-36 95.86 1.14 163.49
-37 21.67 1.08 188.90
-38 16.15 0.32 169.18
-39 39.76 2.45 111.22
-40 16.23 2.15 142.99
-41 13.15 1.05 58.28
-42 46.66 0.30 45.97
-43 67.64 2.28 23.28
-44 98.52 1.71 10.28
-45 96.39 1.11 59.34
-46 96.30 0.67 159.19
-47 45.94 0.62 169.54
-48 20.28 1.78 145.46
-49 44.08 1.57 169.84
-50 80.91 2.13 67.70
+1 33.799999 1.620000 64.500000
+2 45.970001 1.210000 193.570007
+3 91.029999 0.570000 79.360001
+4 59.320000 0.710000 100.989998
+5 34.180000 1.430000 42.439999
+6 75.430000 2.430000 57.860001
+7 26.110001 2.320000 155.970001
+8 31.889999 0.920000 190.940002
+9 90.739998 0.590000 61.869999
+10 15.630000 1.810000 148.949997
+11 62.080002 1.470000 185.779999
+12 84.459999 2.000000 49.139999
+13 71.739998 0.460000 177.149994
+14 81.589996 1.080000 69.269997
+15 76.089996 1.280000 92.169998
+16 50.919998 2.370000 28.139999
+17 73.269997 1.070000 142.009995
+18 99.080002 2.160000 5.510000
+19 76.330002 1.280000 66.870003
+20 47.910000 1.280000 14.790000
+21 49.919998 0.920000 86.800003
+22 88.980003 1.180000 127.610001
+23 11.720000 1.970000 189.639999
+24 22.719999 0.560000 106.910004
+25 99.430000 1.610000 52.189999
+26 73.169998 1.780000 112.360001
+27 17.100000 2.260000 72.910004
+28 96.589996 2.430000 43.500000
+29 16.389999 1.360000 77.739998
+30 47.779999 1.850000 36.029999
+31 12.490000 0.960000 170.419998
+32 53.070000 0.320000 83.830002
+33 42.259998 0.720000 198.570007
+34 86.220001 1.030000 195.660004
+35 46.830002 0.370000 23.290001
+36 95.860001 1.140000 163.490005
+37 21.670000 1.080000 188.899994
+38 16.150000 0.320000 169.179993
+39 39.759998 2.450000 111.220001
+40 16.230000 2.150000 142.990005
+41 13.150000 1.050000 58.279999
+42 46.660000 0.300000 45.970001
+43 67.639999 2.280000 23.280001
+44 98.519997 1.710000 10.280000
+45 96.389999 1.110000 59.340000
+46 96.300003 0.670000 159.190002
+47 45.939999 0.620000 169.539993
+48 20.280001 1.780000 145.460007
+49 44.080002 1.570000 169.839996
+50 80.910004 2.130000 67.699997
diff --git a/src/clients.txt b/src/clients.txt
index 783ee8e..702f0fb 100644
--- a/src/clients.txt
+++ b/src/clients.txt
@@ -1,50 +1,50 @@
-1 7062 115.95 0 1
-2 9392 446.75 0 0
-3 7920 418.33 1 0
-4 371 288.01 0 0
-5 3762 175.85 0 0
-6 3427 404.05 0 0
-7 6861 148.23 0 0
-8 57 201.61 0 0
-9 6877 348.38 1 0
-10 2497 66.83 0 0
-11 5511 34.30 0 0
-12 3377 236.79 0 0
-13 8021 209.12 0 0
-14 7696 283.08 0 0
-15 4792 201.22 1 1
-16 1423 334.40 0 0
-17 919 360.44 0 0
-18 3297 105.79 0 0
-19 3569 410.50 0 0
-20 457 69.42 0 0
-21 8400 146.92 0 0
-22 6401 205.69 0 0
-23 4585 310.51 0 0
-24 6228 406.27 0 0
-25 635 12.86 0 0
-26 9770 486.48 0 0
-27 6919 67.96 0 0
-28 6703 252.47 0 0
-29 708 52.76 0 0
-30 4440 425.78 0 0
-31 5768 433.09 0 0
-32 9810 442.02 0 0
-33 6220 256.28 0 0
-34 5317 473.44 0 0
-35 3284 370.82 0 0
-36 2998 426.58 0 0
-37 8975 425.60 0 0
-38 5877 106.48 0 0
-39 1957 343.13 0 0
-40 9020 378.99 0 0
-41 9675 163.61 0 0
-42 8637 288.33 0 0
-43 5125 350.72 0 0
-44 1318 79.63 0 0
-45 2598 251.03 0 0
-46 8815 302.61 0 0
-47 8916 143.71 0 0
-48 1503 452.92 0 0
-49 7690 435.32 0 0
-50 2999 57.94 0 0
+1 7062 115.949997 1 0
+2 9392 446.750000 0 0
+3 7920 418.329987 1 0
+4 371 288.010010 0 0
+5 3762 175.850006 0 0
+6 3427 404.049988 0 0
+7 6861 148.229996 0 0
+8 57 201.610001 0 0
+9 6877 348.380005 0 1
+10 2497 66.830002 0 0
+11 5511 34.299999 0 0
+12 3377 236.789993 0 0
+13 8021 209.119995 0 0
+14 7696 283.079987 0 0
+15 4792 201.220001 1 1
+16 1423 334.399994 0 0
+17 919 360.440002 0 0
+18 3297 105.790001 0 0
+19 3569 410.500000 0 0
+20 457 69.419998 0 0
+21 8400 146.919998 0 0
+22 6401 205.690002 0 0
+23 4585 310.510010 0 0
+24 6228 406.269989 0 0
+25 635 12.860000 0 0
+26 9770 486.480011 0 0
+27 6919 67.959999 0 0
+28 6703 252.470001 0 0
+29 708 52.759998 0 0
+30 4440 425.779999 0 0
+31 5768 433.089996 0 0
+32 9810 442.019989 0 0
+33 6220 256.279999 0 0
+34 5317 473.440002 0 0
+35 3284 370.820007 0 0
+36 2998 426.579987 0 0
+37 8975 425.600006 0 0
+38 5877 106.480003 0 0
+39 1957 343.130005 0 0
+40 9020 378.989990 0 0
+41 9675 163.610001 0 0
+42 8637 288.329987 0 0
+43 5125 350.720001 0 0
+44 1318 79.629997 0 0
+45 2598 251.029999 0 0
+46 8815 302.609985 0 0
+47 8916 143.710007 0 0
+48 1503 452.920013 0 0
+49 7690 435.320007 0 0
+50 2999 57.939999 0 0
diff --git a/src/debug.c b/src/debug.c
index 6a0cb58..41273e5 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -5,6 +5,7 @@
#include "main.h"
+//TODO Non-terminé
void debugMenu(int tabReference[], float tabWeight[], float tabVolume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[], int isAdmin[], int tlogArticle, int tlogClient)
{
int choice;
diff --git a/src/errorHandling.c b/src/errorHandling.c
index c49b8f8..09f1e63 100644
--- a/src/errorHandling.c
+++ b/src/errorHandling.c
@@ -46,7 +46,7 @@ void errorHandling(int error)
printf("[ERREUR] - Le mot de passe est incorrect.\n");
break;
case -10:
- printf("[ERREUR] - Le client est suspendu.\n");
+ printf("[ERREUR] - Votre compte est suspendu.\n");
break;
case -11:
printf("[ERREUR] - Le client n'est pas administrateur.\n");
diff --git a/src/exe b/src/exe
index 022499c..8b066f8 100644
Binary files a/src/exe and b/src/exe differ
diff --git a/src/login.c b/src/login.c
index dec0d54..8b98a89 100644
--- a/src/login.c
+++ b/src/login.c
@@ -10,9 +10,10 @@
* @param clientID: Tableau des identifiants client
* @param isAdmin: Tableau des statuts Administrateur des clients
* @param tlog: Taille logique des Tableaux
+ * @param suspended: Tableau des états de compte client
* @return Est Admin ? (1 > Oui, 0 > Non, -1 > Quitter)
*/
-int login(int clientID[], int clientPassword[], int isAdmin[], int tlog, int *index)
+int login(int clientID[], int clientPassword[], int isAdmin[], int suspended[], int tlog, int *index)
{
int id, password, found, tentative=3;
printf("Entrez votre identifiant: ");
@@ -42,6 +43,12 @@ int login(int clientID[], int clientPassword[], int isAdmin[], int tlog, int *in
*index = searchTab(clientID, id, tlog, &found);
}
+ if(suspended[*index] == 1)
+ {
+ errorHandling(-10);
+ return -10;
+ }
+
printf("Entrez votre mot de passe: ");
scanf("%d%*c", &password);
while (password < 0)
diff --git a/src/main.c b/src/main.c
index b6a7408..13fedc8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -62,7 +62,7 @@ void global(void)
switch(choice)
{
case 1:
- status = login(clientID, clientPassword, isAdmin, tLogClient, &index);
+ status = login(clientID, clientPassword, isAdmin, suspended, tLogClient, &index);
if(status == 1)
{
adminMenu(clientID, clientPassword, cagnotte, suspended, isAdmin, reference, weight, volume, unitPrice, &tLogItem, &tLogClient);
@@ -95,7 +95,7 @@ void global(void)
break;
case 4:
sauvegardeDonnees(tLogItem, tLogClient, reference, weight, volume, unitPrice, clientID, clientPassword, cagnotte, isAdmin, suspended);
- return;
+ break;
case 9:
debugMenu(reference, weight, volume, unitPrice, clientID, cagnotte, suspended, isAdmin, tLogItem, tLogClient);
break;
@@ -106,6 +106,7 @@ void global(void)
}
choice = displayMenu();
}
+ sauvegardeDonnees(tLogItem, tLogClient, reference, weight, volume, unitPrice, clientID, clientPassword, cagnotte, isAdmin, suspended);
}
/**
diff --git a/src/main.h b/src/main.h
index ce76bad..b37be4e 100644
--- a/src/main.h
+++ b/src/main.h
@@ -59,7 +59,7 @@ void reinit_basket(int *tlog_basket);
void basket_del_article(int basket_tab_ref[], int basket_tab_qte[], int *tlog_basket);
//! LOGIN
-int login(int clientID[], int clientPassword[], int isAdmin[], int tlog, int *index);
+int login(int clientID[], int clientPassword[], int isAdmin[], int suspended[], int tlog, int *index);
int signup(int clientID[], int clientPassword[], float cagnotte[], int suspended[], int isAdmin[], int *tlog);
//! MENUS
diff --git a/src/menu.c b/src/menu.c
index e29e3d1..66b54dc 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -44,7 +44,7 @@ void clientMenu(float *weight, float *volume, float *price, int tabItemRef[], fl
printf("6\u2022 Déconnexion\n");
printf("=================================\n");
printf("Votre choix: ");
- scanf("%d", &choice);
+ scanf("%d%*c", &choice);
system("clear");
@@ -122,7 +122,7 @@ void adminMenu(int clientID[], int clientPassword[], float cagnotte[], int suspe
printf("10\u2022 Déconnexion\n");
printf("=================================\n");
printf("Votre choix: ");
- scanf("%d", &choice);
+ scanf("%d%*c", &choice);
system("clear");
diff --git a/src/traitement.c b/src/traitement.c
index 7670ed0..61afa89 100644
--- a/src/traitement.c
+++ b/src/traitement.c
@@ -131,6 +131,8 @@ int chargeClients(int clientID[], int clientPassword[], float cagnotte[], int su
*/
void sauvegardeDonnees(int tLogArticle, int tLogClient, int reference[], float weight[], float volume[], float unitPrice[], int clientID[], int clientPassword[], float cagnotte[], int suspended[], int isAdmin[])
{
+ printf("[DEBUG] - Sauvegarde des données...\n");
+ sleep(2);
sauvegardeArticles(reference, weight, volume, unitPrice, tLogArticle);
sauvegardeClients(clientID, clientPassword, cagnotte, suspended, isAdmin, tLogClient);
}
@@ -159,6 +161,7 @@ void sauvegardeArticles(int reference[], float weight[], float volume[], float u
fprintf(article, "%d %f %f %f\n", reference[i], weight[i], volume[i], unitPrice[i]);
}
+ printf("[DEBUG] - Sauvegarde articles réussie.\n");
fclose(article);
}
@@ -187,5 +190,6 @@ void sauvegardeClients(int clientID[], int clientPassword[], float cagnotte[], i
fprintf(client, "%d %d %f %d %d\n", clientID[i], clientPassword[i], cagnotte[i], suspended[i], isAdmin[i]);
}
+ printf("[DEBUG] - Sauvegarde clients réussie.\n");
fclose(client);
}
\ No newline at end of file