From 03c40541a5dff909327359aa7d4045367081e480 Mon Sep 17 00:00:00 2001 From: MassiveAtoms Date: Sun, 21 Jul 2019 21:25:51 -0300 Subject: [PATCH] aaaaaaaaaaaa --- Interface.cpp | 8 ++++++++ Park_time.cpp | 2 +- Query.cpp | 25 ++++++++++++++++++------- data.cpp | 2 +- headers/Interface.h | 3 ++- 5 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Interface.cpp b/Interface.cpp index 06a6c34..ca17dda 100644 --- a/Interface.cpp +++ b/Interface.cpp @@ -70,6 +70,8 @@ void interface_admin(vector& spots) { cout << "[2] See weekly report of ALL parking spots\n"; cout << "[3] See monthly 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 << "[6] See weekly report of a specific customer\n"; cout << "Enter option number: "; int option_1; cin >> option_1; @@ -91,6 +93,12 @@ void interface_admin(vector& spots) { report_single_spot(true); break; } + case 5: { + report_customer(0); + } + case 6: { + report_customer(0, true); + } default: break; } diff --git a/Park_time.cpp b/Park_time.cpp index 53811ef..aa0ac0b 100644 --- a/Park_time.cpp +++ b/Park_time.cpp @@ -60,7 +60,7 @@ std::ostream& operator<<(std::ostream& os, const Park_time& pt) { os << "Customer # " << pt.customer_id << "at parking spot " << pt.spot_id << "\n"; os << "Clocked in :" << std::ctime(&start_); os << "clocked out : " << std::ctime(&end_); - os << "duration : " << pt.duration << "\n"; + os << "duration : " << pt.duration/3600 << "\n"; os << "- - - - - - - - - - - - - - - - - - - -\n"; return os; } diff --git a/Query.cpp b/Query.cpp index 0dbac1d..12a7d03 100644 --- a/Query.cpp +++ b/Query.cpp @@ -135,35 +135,46 @@ void reports_from_allparkspots(pair period) { } void current_status_parkspots(vector& spots) { + cout << "P.spot \t\tStatus\t\t Customer\n"; for (auto& i : spots) { - cout << "---------------------------\n"; - cout << "PS #" << i.id << "\n"; - cout << "Taken: " << ((i.taken) ? "true" : "false") << "\n"; + cout << "\n"<< i.id << "\t\t" << ((i.taken) ? "true" : "false"); if (i.taken) { - cout << "Customer#" << i.parked_customer << " parked there\n"; + cout << "\t\t" << i.parked_customer; } } + cout << "\n"; } vector reports_from_customer(int cid, pair period) { vector park_times; + // debug + cout << "it called"; SQLite::Statement query( - data::db, "SELECT * FROM Park_time WHERE customer_id = ? AND start > ? AND end < ?;"); + data::db, "SELECT * FROM Park_time WHERE 'customer_id' = '?' AND start > ? AND end < ?;"); query.bind(1, cid); query.bind(2, period.first); query.bind(3, period.second); while (query.executeStep()) { - int id = query.getColumn(0); + int id = query.getColumn(1); int spotid = query.getColumn(2); int start = query.getColumn(3); - int duration = query.getColumn(5); + int duration = query.getColumn(6); Park_time result{id, cid, spotid, start, duration}; park_times.push_back(result); } query.reset(); + SQLite::Statement vtype(data::db, "SELECT * FROM Customer WHERE 'id' = '?' ;"); + query.bind(1, cid); + int verhicle = 0; + while (vtype.executeStep()) { + verhicle = query.getColumn(4); + } + float sum; for (auto i : park_times) { cout << i; + sum += i.duration/3600; } + cout << "Your fees for this month: $" << sum << "/n"; return park_times; } \ No newline at end of file diff --git a/data.cpp b/data.cpp index 3a3737b..2f4e599 100644 --- a/data.cpp +++ b/data.cpp @@ -20,7 +20,7 @@ SQLite::Database start_db() { } db.exec( "create table if not exists Customer (id integer primary key, name " - "text, password text, vehicle int, telephone text)"); + "text, password text, vehicle int, telephone text, role int, address text)"); db.exec( "create table if not exists Park_spot (id integer primary key, taken " "int, customer_id int, vehicle_type int)"); diff --git a/headers/Interface.h b/headers/Interface.h index b7171c3..7cf6935 100644 --- a/headers/Interface.h +++ b/headers/Interface.h @@ -16,4 +16,5 @@ pair create_week_period(); // report stuff void report_single_spot(bool weekly = false); -void report_all_spots(bool weekly = false); \ No newline at end of file +void report_all_spots(bool weekly = false); +void report_customer(int customerID, bool weekly = false);