-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
85 lines (76 loc) · 2.36 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "Authentication.h"
#include "owner.h"
#include "CRUD.h"
#include "Inventory.h"
#include "cart.h"
#include "coupon.h"
#include "beautiful_cli.h"
#include "customer.h"
#ifdef _WIN32
#include <windows.h>
#endif
void enable_ansi_colors()
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwMode = 0;
GetConsoleMode(hOut, &dwMode);
dwMode |= 0x0004; // ENABLE_VIRTUAL_TERMINAL_PROCESSING
SetConsoleMode(hOut, dwMode);
}
// Compilenation code
// gcc -mconsole -std=gnu11 -o program -I./Sub-Interface -I./Features main.c Sub-Interface/beautiful_cli.c Sub-Interface/owner.c Sub-Interface/customer.c Features/coupon.c Features/cart.c Features/CRUD.c Features/Inventory.c Features/Authentication.c Features/report.c Features/logging.c
int result;
int main()
{
enable_ansi_colors();
inventory_load(inv, inventory_csv);
product_load(prod, product_csv);
coupon_load(cou, coupon_csv);
Load_cart(cart_csv);
Process_Scheduled_Purchases(scheduled_csv);
sync_inventory_with_product(inventory_csv, product_csv);
delete_expired_coupons(cou);
int choice;
do
{
// Display the menu
printf("\n======================================\n");
printf(" Inventory System Management\n");
printf("======================================\n");
printf("1. Create Customer User\n");
printf("2. Login Customer User\n");
printf("3. Login Owner User\n");
printf("0. Exit\n");
printf("======================================\n");
printf("Enter your choice: ");
scanf("%d", &choice);
clearScreen();
// Handle user input
switch (choice)
{
case 1:
add_new_user(authentication_csv, 0);
break;
case 2:
result = loginUser(authentication_csv, 0);
if (result)
customerPrivilegesMenu();
break;
case 3:
result = loginUser(authentication_csv, 1);
if (result)
ownerPrivilegesMenu();
break;
case 0:
printf("\nExiting... Thank you for using the system!\n");
break;
default:
printf("\nInvalid choice! Please try again.\n");
}
} while (choice != 0);
return 0;
}