cosmetic merge
This commit is contained in:
parent
aa52f96beb
commit
ef607e7ffc
149
Interface.cpp
149
Interface.cpp
@ -1,17 +1,18 @@
|
|||||||
#include "headers/Interface.h"
|
#include "headers/Interface.h"
|
||||||
|
|
||||||
// I added it to pass spots, because the parking options need it to check where
|
// I added it to pass spots, because the parking options need it to check where
|
||||||
// is free parking_spots is declared in main, and if i declare it
|
// is free parking_spots is declared in main, and if i declare it
|
||||||
// liberal use of
|
// liberal use of
|
||||||
// cin.ignore(10000, '\n');
|
// cin.ignore(10000, '\n');
|
||||||
// so it skips to the next newline, in essence clearing the cin buffer
|
// so it skips to the next newline, in essence clearing the cin buffer
|
||||||
|
|
||||||
void interface(vector<Park_spot>& spots) {
|
void interface(vector<Park_spot>& spots) {
|
||||||
/*
|
/*
|
||||||
string introduction = "P A R K M A N N E"; //logo animation, disable during testing
|
string introduction = "P A R K M A N N E"; //logo animation, disable during testing
|
||||||
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;
|
||||||
@ -35,14 +36,15 @@ void interface(vector<Park_spot>& spots) {
|
|||||||
} else {
|
} else {
|
||||||
cout << "ERROR ROLE_INVALID!";
|
cout << "ERROR ROLE_INVALID!";
|
||||||
}
|
}
|
||||||
exit:;
|
exit:;
|
||||||
}
|
}
|
||||||
|
|
||||||
void interface_member(vector<Park_spot>& spots, Customer& c) {
|
void interface_member(vector<Park_spot>& spots, Customer& c) {
|
||||||
__label__ begin, exit;
|
__label__ begin, exit;
|
||||||
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";
|
||||||
@ -55,17 +57,21 @@ begin:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
cout << "Has not been implemented yet\n";
|
report_customer(c.id);
|
||||||
|
string lol;
|
||||||
|
std::cout<<"Enter any character to continue...";
|
||||||
|
std::cin>>lol;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3: {
|
case 3: {
|
||||||
cout << "Has not been implemented yet\n";
|
edit_information(c);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 4: {
|
case 4: {
|
||||||
cout << "Exiting...\n";
|
cout << "Exiting...\n";
|
||||||
|
Sleep(2000);
|
||||||
goto exit;
|
goto exit;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -74,12 +80,13 @@ begin:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
goto begin;
|
goto begin;
|
||||||
exit:;
|
exit:;
|
||||||
}
|
}
|
||||||
|
|
||||||
void interface_admin(vector<Park_spot>& spots) {
|
void interface_admin(vector<Park_spot>& spots) {
|
||||||
__label__ begin, exit;
|
__label__ begin, exit;
|
||||||
begin:
|
begin:
|
||||||
|
system("CLS");
|
||||||
cout << "\nWelcome to the admin interface\n";
|
cout << "\nWelcome to the admin interface\n";
|
||||||
cout << "\n[1] Reports & analytics";
|
cout << "\n[1] Reports & analytics";
|
||||||
cout << "\n[2] Parking spots";
|
cout << "\n[2] Parking spots";
|
||||||
@ -97,6 +104,7 @@ begin:
|
|||||||
cout << "[4] See weekly report of a specific parking spot\n";
|
cout << "[4] See weekly report of a specific parking spot\n";
|
||||||
cout << "[5] See monthly report of a specific customer\n";
|
cout << "[5] See monthly report of a specific customer\n";
|
||||||
cout << "[6] See weekly report of a specific customer\n";
|
cout << "[6] See weekly report of a specific customer\n";
|
||||||
|
cout << "[7] Return\n";
|
||||||
cout << "Enter option number: ";
|
cout << "Enter option number: ";
|
||||||
int option_1;
|
int option_1;
|
||||||
cin >> option_1;
|
cin >> option_1;
|
||||||
@ -126,9 +134,17 @@ begin:
|
|||||||
report_customer(0, true);
|
report_customer(0, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 7: {
|
||||||
|
goto begin;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
string lol;
|
||||||
|
std::cout<<"Enter any character to continue...";
|
||||||
|
std::cin>>lol;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
cout << "[1] See current status of parking spots\n";
|
cout << "[1] See current status of parking spots\n";
|
||||||
@ -141,6 +157,9 @@ begin:
|
|||||||
switch (option_2) {
|
switch (option_2) {
|
||||||
case 1: {
|
case 1: {
|
||||||
current_status_parkspots(spots);
|
current_status_parkspots(spots);
|
||||||
|
string lol;
|
||||||
|
std::cout<<"Enter any character to continue...";
|
||||||
|
std::cin>>lol;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
@ -154,9 +173,11 @@ begin:
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
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";
|
||||||
@ -181,6 +202,8 @@ begin:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 4: {
|
case 4: {
|
||||||
|
std::cout<<"Exiting...";
|
||||||
|
Sleep(2000);
|
||||||
goto exit;
|
goto exit;
|
||||||
break;
|
break;
|
||||||
} break;
|
} break;
|
||||||
@ -190,12 +213,13 @@ begin:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
goto begin;
|
goto begin;
|
||||||
exit:;
|
exit:;
|
||||||
}
|
|
||||||
|
|
||||||
// --------- individual things.
|
}
|
||||||
|
|
||||||
void park(Customer& c, vector<Park_spot>& spots) {
|
// --------- individual things.
|
||||||
|
|
||||||
|
void park(Customer& c, vector<Park_spot>& spots) {
|
||||||
__label__ exit;
|
__label__ exit;
|
||||||
cout << "You have selected parking option.\n";
|
cout << "You have selected parking option.\n";
|
||||||
if (!(c.parked())) {
|
if (!(c.parked())) {
|
||||||
@ -231,13 +255,13 @@ 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."; // exit to customer login
|
cout << "OK, have a nice day.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exit:;
|
exit:;
|
||||||
}
|
}
|
||||||
|
|
||||||
void new_customer() {
|
void new_customer() {
|
||||||
int vtype;
|
int vtype;
|
||||||
string name;
|
string name;
|
||||||
string password;
|
string password;
|
||||||
@ -256,9 +280,9 @@ void new_customer() {
|
|||||||
cout << "\nNew customer sucessfully created\n";
|
cout << "\nNew customer sucessfully created\n";
|
||||||
if (confirm())
|
if (confirm())
|
||||||
newcustomer.update_db();
|
newcustomer.update_db();
|
||||||
}
|
}
|
||||||
|
|
||||||
void new_admin() {
|
void new_admin() {
|
||||||
int vtype = 2; // revision required! Needs to be set to NULL
|
int vtype = 2; // revision required! Needs to be set to NULL
|
||||||
string name;
|
string name;
|
||||||
string password;
|
string password;
|
||||||
@ -274,10 +298,10 @@ void new_admin() {
|
|||||||
cout << "\nNew customer sucessfully created\n";
|
cout << "\nNew customer sucessfully created\n";
|
||||||
if (confirm())
|
if (confirm())
|
||||||
newcustomer.update_db();
|
newcustomer.update_db();
|
||||||
}
|
}
|
||||||
|
|
||||||
void new_parkspot(vector<Park_spot>& spots) {
|
void new_parkspot(vector<Park_spot>& spots) {
|
||||||
cout << "What type of parking spot? \n[1] Twowheeler\n[2] Fourwheeler\n";
|
cout << "What type of parking spot? \n[1] Two-wheeler\n[2] Four-wheeler\n";
|
||||||
int vtype;
|
int vtype;
|
||||||
cin >> vtype;
|
cin >> vtype;
|
||||||
cin.ignore(10000, '\n');
|
cin.ignore(10000, '\n');
|
||||||
@ -286,11 +310,38 @@ void new_parkspot(vector<Park_spot>& spots) {
|
|||||||
spots.push_back(newspot);
|
spots.push_back(newspot);
|
||||||
cout << "New parking spot sucessfully created.\n";
|
cout << "New parking spot sucessfully created.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// time stuff-----------------------------------------------------
|
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;*/
|
||||||
|
|
||||||
pair<int, int> create_month_period() {
|
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-----------------------------------------------------
|
||||||
|
|
||||||
|
pair<int, int> create_month_period() {
|
||||||
std::time_t t = std::time(0);
|
std::time_t t = std::time(0);
|
||||||
std::tm* date = std::localtime(&t);
|
std::tm* date = std::localtime(&t);
|
||||||
int month, year = 0;
|
int month, year = 0;
|
||||||
@ -304,9 +355,9 @@ pair<int, int> create_month_period() {
|
|||||||
date->tm_mon = month;
|
date->tm_mon = month;
|
||||||
period.second = mktime(date);
|
period.second = mktime(date);
|
||||||
return period;
|
return period;
|
||||||
}
|
}
|
||||||
|
|
||||||
pair<int, int> create_week_period() {
|
pair<int, int> create_week_period() {
|
||||||
std::time_t t = std::time(0);
|
std::time_t t = std::time(0);
|
||||||
std::tm* date = std::localtime(&t);
|
std::tm* date = std::localtime(&t);
|
||||||
int day, month, year = 0;
|
int day, month, year = 0;
|
||||||
@ -321,23 +372,31 @@ pair<int, int> create_week_period() {
|
|||||||
period.first = mktime(date);
|
period.first = mktime(date);
|
||||||
period.second = period.first + 604800; // plus 7 days in seconds.
|
period.second = period.first + 604800; // plus 7 days in seconds.
|
||||||
return period;
|
return period;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool confirm(void) {
|
bool confirm(void) {
|
||||||
string ver;
|
string ver;
|
||||||
std::cout << "\nAre you sure you want to commit these actions?"
|
std::cout << "\nAre you sure you want to commit these actions?"
|
||||||
"\n[No] Revert."
|
"\n[No] Revert."
|
||||||
"\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
|
||||||
|
|
||||||
void report_all_spots(bool weekly) {
|
void report_all_spots(bool weekly) {
|
||||||
pair<int, int> period;
|
pair<int, int> period;
|
||||||
if (weekly) {
|
if (weekly) {
|
||||||
period = create_week_period(); // remove the pair<int, int>
|
period = create_week_period(); // remove the pair<int, int>
|
||||||
@ -348,9 +407,9 @@ void report_all_spots(bool weekly) {
|
|||||||
cout << "working timeperiods: " << period.first << ", " << period.second; // DEBUG
|
cout << "working timeperiods: " << period.first << ", " << period.second; // DEBUG
|
||||||
|
|
||||||
reports_from_allparkspots(period); // TODO: namechange of reports_from_allparkspots in query?
|
reports_from_allparkspots(period); // TODO: namechange of reports_from_allparkspots in query?
|
||||||
}
|
}
|
||||||
|
|
||||||
void report_single_spot(bool weekly) {
|
void report_single_spot(bool weekly) {
|
||||||
cout << "Which parking spot would you like a report on?\n";
|
cout << "Which parking spot would you like a report on?\n";
|
||||||
cout << "Parking spot ID: ";
|
cout << "Parking spot ID: ";
|
||||||
int spotID;
|
int spotID;
|
||||||
@ -363,9 +422,9 @@ void report_single_spot(bool weekly) {
|
|||||||
period = create_month_period();
|
period = create_month_period();
|
||||||
}
|
}
|
||||||
reports_from_parkspot(spotID, period);
|
reports_from_parkspot(spotID, period);
|
||||||
}
|
}
|
||||||
|
|
||||||
void report_customer(int customerID, bool weekly) {
|
void report_customer(int customerID, bool weekly) {
|
||||||
// use report_customer(0) to make interactive
|
// use report_customer(0) to make interactive
|
||||||
// so admin can call the interactive version, but customer can only call
|
// so admin can call the interactive version, but customer can only call
|
||||||
// report_customer(own_cid)
|
// report_customer(own_cid)
|
||||||
@ -380,4 +439,4 @@ void report_customer(int customerID, bool weekly) {
|
|||||||
period = create_month_period();
|
period = create_month_period();
|
||||||
}
|
}
|
||||||
reports_from_customer(customerID, period);
|
reports_from_customer(customerID, period);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user