-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathglobalfunctions.h
More file actions
47 lines (39 loc) · 1.55 KB
/
globalfunctions.h
File metadata and controls
47 lines (39 loc) · 1.55 KB
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
#ifndef GLOBALFUNCTIONS_H
#define GLOBALFUNCTIONS_H
#include <QString>
#include <QSqlQuery>
#include <QSqlError>
#include <QDebug>
#include <QMap>
class GlobalFunctions
{
private:
static QString username; // Static member to store username
static int user_ID; // Static member to store user ID
static QMap<QString, bool> permissions; // Store user permissions
static QString hashPasswordWithSalt(const QString &password, const QString &salt);
static bool admin;
public:
GlobalFunctions();
static QString business_name;
static QString business_logo_path;
// Declare static methods
static bool verifyPassword(const QString &enteredPassword, const QString &storedHash, const QString &storedSalt);
static void set_user(const QString &name, const int &id);
static QString get_username(); // Getter for username
static int get_user_id(); // Getter for user ID
static void audit_logs(const QString &action, const QString &details);
static void set_admin();
static bool is_admin();
static void get_business_info(QString &business_name,QString &business_logo_path);
static void log_user_login();
static void log_user_logout();
static void log_add_product();
static void log_add_sale();
static void log_update_record();
static void log_delete_record();
// New static function to load user permissions
static bool loadPermissions();
static bool hasPermission(const QString &permission); // Check if user has specific permission
};
#endif // GLOBALFUNCTIONS_H