Ajout de la fonction d'opposition
continuous-integration/drone/push Build is passing Details

master
Rémi LAVERGNE 1 year ago
parent 7acae0bc42
commit e423594cbb

@ -15,7 +15,7 @@ void errorHandling(int error)
//? Exemple d'erreurs (à adapter)
if (error < 0)
{
printf("\a"); // Bip d'erreur
printf("\a \x1B[31m"); // Bip d'erreur
switch (error)
{
case -1:
@ -49,11 +49,12 @@ void errorHandling(int error)
printf("[ERREUR] - Une erreur s'est produite.\n");
break;
}
printf("\x1B[0m");
}
}
/**
* La fonction `debugHandling` aide au debug en écrivant du texte selon l'entrée.
* @brief La fonction `debugHandling` aide au debug en écrivant du texte selon l'entrée.
*
* @param code Entier qui représente l'entrée.
*/

Binary file not shown.

@ -88,6 +88,12 @@ int signup(int clientID[], int clientPassword[], float cagnotte[], int suspended
printf("Erreur, l'identifiant doit être positif, entrez votre identifiant ou 0 si vous souhaitez quitter: ");
scanf("%d%*c", &id);
}
if (id == 0)
{
errorHandling(-1);
return -1;
}
index = searchTab(clientID, id, *tlog, &found);
while(found == 1)
{
@ -95,6 +101,7 @@ int signup(int clientID[], int clientPassword[], float cagnotte[], int suspended
scanf("%d%*c", &id);
if (id == 0)
{
errorHandling(-1);
return -1;
}
index = searchTab(clientID, id, *tlog, &found);

@ -17,7 +17,6 @@ int displayMenu(void)
int choice;
printf("\nTapez sur Entrée pour continuer...");
//TODO Clear le buffer pour éviter les problèmes
if (getchar() == '\n') // getchar() pour récupérer le caractère entré par l'utilisateur
{
system("clear"); // Clear le terminal
@ -75,7 +74,7 @@ void global(void)
else
{
printf("Connexion échouée.\nRetour au menu principal...\n");
sleep(3);
sleep(2);
}
break;
case 2:
@ -92,8 +91,7 @@ void global(void)
}
break;
case 3:
//TODO > Faire opposition
//opposition();
opposition(clientID, clientPassword, suspended, tLogClient);
break;
case 4:
sauvegardeDonnees(tLogItem, tLogClient, reference, weight, volume, unitPrice, clientID, clientPassword, cagnotte, isAdmin, suspended);

@ -69,4 +69,5 @@ int decrypt(int password);
//! MENUS
void adminMenu(int clientID[], int clientPassword[], float cagnotte[], int suspended[], int isAdmin[], int tabReference[], float tabWeight[], float tabVolume[], float unitPrice[], int *tlogItem, int *tlogClient);
void clientMenu(float *weight, float *volume, float *price, int tabItemRef[], float unitPrice[], float *cagnotte, int basket_tab_ref[], int basket_tab_qte[], float tabWeight[], float tabVolume[], int tlogItem, int *tlogBasket);
void clientMenu(float *weight, float *volume, float *price, int tabItemRef[], float unitPrice[], float *cagnotte, int basket_tab_ref[], int basket_tab_qte[], float tabWeight[], float tabVolume[], int tlogItem, int *tlogBasket);
void opposition(int clientID[], int clientPassword[], int suspended[], int tlogClient)

@ -69,7 +69,7 @@ void clientMenu(float *weight, float *volume, float *price, int tabItemRef[], fl
}
/**
* La fonction `adminMenu` permet à l'utilisateur administrateur de pouvoir utiliser des fonctions permettant
* @brief La fonction `adminMenu` permet à l'utilisateur administrateur de pouvoir utiliser des fonctions permettant
* d'ajouter/supprimer/modifier des articles du panier/ des clients, et afficher les informations
* du client/de l'article.
*
@ -144,4 +144,37 @@ void adminMenu(int clientID[], int clientPassword[], float cagnotte[], int suspe
break;
}
}
}
/**
* @brief Pour faire opposition et débloquer son compte lorsqu'il est suspendu.
* @param clientID Tableau des identifiants client
* @param clientPassword Tableau des mots de passe
* @param suspended Tableau des états de compte
* @param tlogClient Taille logique du tableau des clients
*
* @return void
*/
void opposition(int clientID[], int clientPassword[], int suspended[], int tlogClient)
{
int id, password, index, found;
printf("Entrez votre identifiant: ");
scanf("%d%*c", &id);
index = searchTab(clientID, id, tlogClient, &found);
if (found == 0)
{
errorHandling(-7);
return;
}
printf("Entrez votre mot de passe: ");
scanf("%d%*c", &password);
if (password == clientPassword[index])
{
suspended[index] = 0;
printf("Votre compte a été réactivé.\n");
}
else
{
errorHandling(-9);
}
}
Loading…
Cancel
Save