fixed customer role
This commit is contained in:
parent
8778a72c29
commit
aa52f96beb
@ -13,13 +13,14 @@ Customer::Customer(string name_, string password_, Vehicle_type vehicle_, string
|
|||||||
}
|
}
|
||||||
|
|
||||||
Customer::Customer(int id_, string name_, string password_, Vehicle_type vehicle_,
|
Customer::Customer(int id_, string name_, string password_, Vehicle_type vehicle_,
|
||||||
vector<Park_time> instances, string telephone_)
|
vector<Park_time> instances, string telephone_, int role_)
|
||||||
: id{id_},
|
: id{id_},
|
||||||
name{name_},
|
name{name_},
|
||||||
password{password_},
|
password{password_},
|
||||||
vehicle{vehicle_},
|
vehicle{vehicle_},
|
||||||
park_instances{instances},
|
park_instances{instances},
|
||||||
telephone{telephone_} {}
|
telephone{telephone_},
|
||||||
|
role{role_} {}
|
||||||
|
|
||||||
// clock in/out methods
|
// clock in/out methods
|
||||||
// ====================================================================================
|
// ====================================================================================
|
||||||
|
@ -12,7 +12,6 @@ void interface(vector<Park_spot>& spots) {
|
|||||||
text_animation(introduction, 50);
|
text_animation(introduction, 50);
|
||||||
*/
|
*/
|
||||||
__label__ exit;
|
__label__ exit;
|
||||||
system("CLS");
|
|
||||||
cout << "\nWelcome to the parking system. Please login...";
|
cout << "\nWelcome to the parking system. Please login...";
|
||||||
int id;
|
int id;
|
||||||
string password;
|
string password;
|
||||||
@ -44,7 +43,6 @@ void interface_member(vector<Park_spot>& spots, Customer& c) {
|
|||||||
cout << "\nLogged in succesfully!\n";
|
cout << "\nLogged in succesfully!\n";
|
||||||
|
|
||||||
begin:
|
begin:
|
||||||
system("CLS");
|
|
||||||
cout << "Hello! " << c.name
|
cout << "Hello! " << c.name
|
||||||
<< ", please select an option:\n[1]Parking\n[2]Monthly report\n"
|
<< ", please select an option:\n[1]Parking\n[2]Monthly report\n"
|
||||||
"[3]Edit information\n[4]Exit\n";
|
"[3]Edit information\n[4]Exit\n";
|
||||||
@ -57,21 +55,17 @@ begin:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
string lol;
|
cout << "Has not been implemented yet\n";
|
||||||
report_customer(c.id);
|
|
||||||
std::cout<<"Enter any character to continue...";
|
|
||||||
std::cin>>lol;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3: {
|
case 3: {
|
||||||
edit_information(c);
|
cout << "Has not been implemented yet\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 4: {
|
case 4: {
|
||||||
cout << "Exiting...\n";
|
cout << "Exiting...\n";
|
||||||
Sleep(2000);
|
|
||||||
goto exit;
|
goto exit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -163,7 +157,6 @@ begin:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
system("CLS");
|
|
||||||
cout << "[1] Make new customer\n";
|
cout << "[1] Make new customer\n";
|
||||||
cout << "[2] Make new admin\n";
|
cout << "[2] Make new admin\n";
|
||||||
cout << "[3] Return\n";
|
cout << "[3] Return\n";
|
||||||
@ -188,8 +181,6 @@ begin:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
std::cout<<"Exiting...";
|
|
||||||
Sleep(2000);
|
|
||||||
goto exit;
|
goto exit;
|
||||||
break;
|
break;
|
||||||
} break;
|
} break;
|
||||||
@ -200,7 +191,6 @@ begin:
|
|||||||
}
|
}
|
||||||
goto begin;
|
goto begin;
|
||||||
exit:;
|
exit:;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------- individual things.
|
// --------- individual things.
|
||||||
@ -241,7 +231,7 @@ void park(Customer& c, vector<Park_spot>& spots) {
|
|||||||
query_parkspot_with_id(c.parked_at(), spots).clock(c);
|
query_parkspot_with_id(c.parked_at(), spots).clock(c);
|
||||||
cout << "You have sucessfully clocked out.";
|
cout << "You have sucessfully clocked out.";
|
||||||
} else {
|
} else {
|
||||||
cout << "OK, have a nice day.";
|
cout << "OK, have a nice day."; // exit to customer login
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit:;
|
exit:;
|
||||||
@ -287,7 +277,7 @@ void new_admin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void new_parkspot(vector<Park_spot>& spots) {
|
void new_parkspot(vector<Park_spot>& spots) {
|
||||||
cout << "What type of parking spot? \n[1] Two-wheeler\n[2] Four-wheeler\n";
|
cout << "What type of parking spot? \n[1] Twowheeler\n[2] Fourwheeler\n";
|
||||||
int vtype;
|
int vtype;
|
||||||
cin >> vtype;
|
cin >> vtype;
|
||||||
cin.ignore(10000, '\n');
|
cin.ignore(10000, '\n');
|
||||||
@ -298,33 +288,6 @@ void new_parkspot(vector<Park_spot>& spots) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void edit_information(Customer& c)
|
|
||||||
{
|
|
||||||
string string0; int int0;
|
|
||||||
/*std::cout<<"\nInput to update name or press [0] to keep name:\n";
|
|
||||||
std::getline(cin,string0);
|
|
||||||
if (string0=="0");
|
|
||||||
else c.name=string0;*/
|
|
||||||
|
|
||||||
std::cout<<"\n Input to update vehicle to [1]Two-Wheeler,"
|
|
||||||
"[2]Four-Wheeler or press [0] to keep vehicle type:\n";
|
|
||||||
std::cin>>int0;
|
|
||||||
if (!int0);
|
|
||||||
else c.vehicle=Vehicle_type(int0);
|
|
||||||
cin.ignore();
|
|
||||||
std::cout<<"\n Input to update password or press [0] to keep current password:\n";
|
|
||||||
std::getline(cin,string0);
|
|
||||||
if (string0=="0");
|
|
||||||
else c.password=hash_password(string0);
|
|
||||||
|
|
||||||
std::cout<<"\n Input to update phone number or press [0] to keep current number:\n";
|
|
||||||
std::getline(cin,string0);
|
|
||||||
if (string0=="0");
|
|
||||||
else c.telephone=string0;
|
|
||||||
c.role=0;
|
|
||||||
if(confirm()){c.update_db();}
|
|
||||||
}
|
|
||||||
|
|
||||||
// time stuff-----------------------------------------------------
|
// time stuff-----------------------------------------------------
|
||||||
|
|
||||||
pair<int, int> create_month_period() {
|
pair<int, int> create_month_period() {
|
||||||
@ -367,17 +330,9 @@ bool confirm(void) {
|
|||||||
"\n[Yes] Commit.";
|
"\n[Yes] Commit.";
|
||||||
std::cin >> ver;
|
std::cin >> ver;
|
||||||
if (ver == "YES" | ver == "Yes" | ver == "yes")
|
if (ver == "YES" | ver == "Yes" | ver == "yes")
|
||||||
{
|
|
||||||
std::cout<<"Succes! Changes Saved.";
|
|
||||||
Sleep(1000);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
std::cout<<"No changes committed.";
|
|
||||||
Sleep(1000);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------ report stuff
|
// ------------------------------ report stuff
|
||||||
|
@ -41,9 +41,10 @@ vector<Customer> query_customer_with_name(string name) {
|
|||||||
string password = query.getColumn(2);
|
string password = query.getColumn(2);
|
||||||
int vehicle = query.getColumn(3); // cast to vehicle
|
int vehicle = query.getColumn(3); // cast to vehicle
|
||||||
string telephone = query.getColumn(4);
|
string telephone = query.getColumn(4);
|
||||||
|
int role = query.getColumn(5);
|
||||||
vector<Park_time> park_instances = query_parktimes_for_customer(id);
|
vector<Park_time> park_instances = query_parktimes_for_customer(id);
|
||||||
result.push_back(
|
result.push_back(
|
||||||
Customer{id, name_, password, Vehicle_type(vehicle), park_instances, telephone});
|
Customer{id, name_, password, Vehicle_type(vehicle), park_instances, telephone, role});
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -63,8 +64,10 @@ Customer query_customer_with_id(int id) {
|
|||||||
string password = query.getColumn(2);
|
string password = query.getColumn(2);
|
||||||
int vehicle = query.getColumn(3); // cast to vehicle
|
int vehicle = query.getColumn(3); // cast to vehicle
|
||||||
string telephone = query.getColumn(4);
|
string telephone = query.getColumn(4);
|
||||||
|
int role = query.getColumn(5);
|
||||||
|
|
||||||
vector<Park_time> park_instances = query_parktimes_for_customer(id);
|
vector<Park_time> park_instances = query_parktimes_for_customer(id);
|
||||||
Customer result{id, name, password, Vehicle_type(vehicle), park_instances, telephone};
|
Customer result{id, name, password, Vehicle_type(vehicle), park_instances, telephone, role};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,9 @@ class Customer {
|
|||||||
Vehicle_type vehicle;
|
Vehicle_type vehicle;
|
||||||
string telephone;
|
string telephone;
|
||||||
int role;
|
int role;
|
||||||
Customer(string name_, string password_, Vehicle_type vehicle_, string telephone_, int role);
|
Customer(string name_, string password_, Vehicle_type vehicle_, string telephone_, int role_);
|
||||||
Customer(int id_, string name_, string password_, Vehicle_type vehicle_,
|
Customer(int id_, string name_, string password_, Vehicle_type vehicle_,
|
||||||
vector<Park_time> instances, string telephone_);
|
vector<Park_time> instances, string telephone_, int role_);
|
||||||
void clock_in(int s_id);
|
void clock_in(int s_id);
|
||||||
void clock_out(int s_id);
|
void clock_out(int s_id);
|
||||||
bool parked();
|
bool parked();
|
||||||
|
Loading…
Reference in New Issue
Block a user